refactor: fix patch structure

This commit is contained in:
inotia00
2024-04-04 04:05:13 +09:00
parent 7d63cbe4a2
commit 324162e561
191 changed files with 996 additions and 1034 deletions

View File

@ -9,9 +9,9 @@ import app.revanced.patches.music.utils.integrations.Constants.COMPATIBLE_PACKAG
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getTargetIndexWithMethodReferenceName import app.revanced.util.getTargetIndexWithMethodReferenceName
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
@Suppress("unused") @Suppress("unused")
@ -27,7 +27,7 @@ object MenuComponentPatch : BaseBytecodePatch(
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
MenuEntryFingerprint.result?.let { MenuEntryFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val textIndex = getTargetIndexWithMethodReferenceName("setText") val textIndex = getTargetIndexWithMethodReferenceName("setText")
val viewIndex = getTargetIndexWithMethodReferenceName("addView") val viewIndex = getTargetIndexWithMethodReferenceName("addView")
@ -40,7 +40,7 @@ object MenuComponentPatch : BaseBytecodePatch(
"invoke-static {v$textRegister, v$viewRegister}, $ACCOUNT_CLASS_DESCRIPTOR->hideAccountMenu(Ljava/lang/CharSequence;Landroid/view/View;)V" "invoke-static {v$textRegister, v$viewRegister}, $ACCOUNT_CLASS_DESCRIPTOR->hideAccountMenu(Ljava/lang/CharSequence;Landroid/view/View;)V"
) )
} }
} ?: throw MenuEntryFingerprint.exception }
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.ACCOUNT, CategoryType.ACCOUNT,

View File

@ -11,9 +11,9 @@ import app.revanced.patches.music.utils.integrations.Constants.COMPATIBLE_PACKAG
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getTargetIndexWithMethodReferenceName import app.revanced.util.getTargetIndexWithMethodReferenceName
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -36,7 +36,7 @@ object HandlePatch : BaseBytecodePatch(
/** /**
* Hide handle in account menu * Hide handle in account menu
*/ */
AccountSwitcherAccessibilityLabelFingerprint.result?.let { result -> AccountSwitcherAccessibilityLabelFingerprint.resultOrThrow().let { result ->
result.mutableMethod.apply { result.mutableMethod.apply {
val textColorIndex = getTargetIndexWithMethodReferenceName("setTextColor") val textColorIndex = getTargetIndexWithMethodReferenceName("setTextColor")
@ -48,12 +48,12 @@ object HandlePatch : BaseBytecodePatch(
"invoke-static {v${textViewInstruction.registerC}, v${textViewInstruction.registerD}}, $ACCOUNT_CLASS_DESCRIPTOR->hideHandle(Landroid/widget/TextView;I)V" "invoke-static {v${textViewInstruction.registerC}, v${textViewInstruction.registerD}}, $ACCOUNT_CLASS_DESCRIPTOR->hideHandle(Landroid/widget/TextView;I)V"
) )
} }
} ?: throw AccountSwitcherAccessibilityLabelFingerprint.exception }
/** /**
* Hide handle in account switcher * Hide handle in account switcher
*/ */
NamesInactiveAccountThumbnailSizeFingerprint.result?.let { NamesInactiveAccountThumbnailSizeFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.startIndex val targetIndex = it.scanResult.patternScanResult!!.startIndex
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
@ -65,7 +65,7 @@ object HandlePatch : BaseBytecodePatch(
""" """
) )
} }
} ?: throw NamesInactiveAccountThumbnailSizeFingerprint.exception }
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.ACCOUNT, CategoryType.ACCOUNT,

View File

@ -10,9 +10,9 @@ import app.revanced.patches.music.utils.integrations.Constants.COMPATIBLE_PACKAG
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getTargetIndexWithReference import app.revanced.util.getTargetIndexWithReference
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
@Suppress("unused") @Suppress("unused")
@ -28,7 +28,7 @@ object TermsContainerPatch : BaseBytecodePatch(
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
TermsOfServiceFingerprint.result?.let { TermsOfServiceFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val insertIndex = getTargetIndexWithReference("/PrivacyTosFooter;->setVisibility(I)V") val insertIndex = getTargetIndexWithReference("/PrivacyTosFooter;->setVisibility(I)V")
val visibilityRegister = val visibilityRegister =
@ -45,7 +45,7 @@ object TermsContainerPatch : BaseBytecodePatch(
""" """
) )
} }
} ?: throw TermsOfServiceFingerprint.exception }
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.ACCOUNT, CategoryType.ACCOUNT,

View File

@ -17,12 +17,12 @@ import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.LikeDis
import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.patches.music.video.information.VideoInformationPatch import app.revanced.patches.music.video.information.VideoInformationPatch
import app.revanced.util.exception
import app.revanced.util.getTargetIndexWithMethodReferenceName import app.revanced.util.getTargetIndexWithMethodReferenceName
import app.revanced.util.getTargetIndexWithReference import app.revanced.util.getTargetIndexWithReference
import app.revanced.util.getWideLiteralInstructionIndex import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.indexOfFirstInstruction import app.revanced.util.indexOfFirstInstruction
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -46,7 +46,7 @@ object ActionBarComponentPatch : BaseBytecodePatch(
) )
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
ActionBarComponentFingerprint.result?.let { ActionBarComponentFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
// hook download button // hook download button
@ -118,9 +118,9 @@ object ActionBarComponentPatch : BaseBytecodePatch(
"invoke-static {v$buttonTypeDownloadRegister}, $ACTIONBAR_CLASS_DESCRIPTOR->setButtonTypeDownload(I)V" "invoke-static {v$buttonTypeDownloadRegister}, $ACTIONBAR_CLASS_DESCRIPTOR->setButtonTypeDownload(I)V"
) )
} }
} ?: throw ActionBarComponentFingerprint.exception }
LikeDislikeContainerFingerprint.result?.let { parentResult -> LikeDislikeContainerFingerprint.resultOrThrow().let { parentResult ->
// Resolves fingerprints // Resolves fingerprints
LikeDislikeContainerVisibilityFingerprint.resolve(context, parentResult.classDef) LikeDislikeContainerVisibilityFingerprint.resolve(context, parentResult.classDef)
@ -151,7 +151,7 @@ object ActionBarComponentPatch : BaseBytecodePatch(
"invoke-static {v$insertRegister}, $ACTIONBAR_CLASS_DESCRIPTOR->hideLikeDislikeButton(Landroid/view/View;)V" "invoke-static {v$insertRegister}, $ACTIONBAR_CLASS_DESCRIPTOR->hideLikeDislikeButton(Landroid/view/View;)V"
) )
} }
} ?: throw LikeDislikeContainerFingerprint.exception }
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.ACTION_BAR, CategoryType.ACTION_BAR,

View File

@ -20,9 +20,9 @@ import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.Interst
import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.patches.shared.litho.LithoFilterPatch import app.revanced.patches.shared.litho.LithoFilterPatch
import app.revanced.util.exception
import app.revanced.util.getWideLiteralInstructionIndex import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Suppress("unused") @Suppress("unused")
@ -62,7 +62,7 @@ object GeneralAdsPatch : BaseBytecodePatch(
* Hides fullscreen ads * Hides fullscreen ads
* Non-litho view, used in some old clients. * Non-litho view, used in some old clients.
*/ */
InterstitialsContainerFingerprint.result?.let { InterstitialsContainerFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val targetIndex = getWideLiteralInstructionIndex(InterstitialsContainer) + 2 val targetIndex = getWideLiteralInstructionIndex(InterstitialsContainer) + 2
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
@ -72,13 +72,13 @@ object GeneralAdsPatch : BaseBytecodePatch(
"invoke-static {v$targetRegister}, $FULLSCREEN_ADS_CLASS_DESCRIPTOR->hideFullscreenAds(Landroid/view/View;)V" "invoke-static {v$targetRegister}, $FULLSCREEN_ADS_CLASS_DESCRIPTOR->hideFullscreenAds(Landroid/view/View;)V"
) )
} }
} ?: throw InterstitialsContainerFingerprint.exception }
/** /**
* Hides fullscreen ads * Hides fullscreen ads
* Litho view, used in 'ShowDialogCommandOuterClass' in innertube * Litho view, used in 'ShowDialogCommandOuterClass' in innertube
*/ */
ShowDialogCommandFingerprint.result?.let { ShowDialogCommandFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
// In this method, custom dialog is created and shown. // In this method, custom dialog is created and shown.
// There were no issues despite adding “return-void” to the first index. // There were no issues despite adding “return-void” to the first index.
@ -125,12 +125,12 @@ object GeneralAdsPatch : BaseBytecodePatch(
// """ // """
// ) // )
} }
} ?: throw ShowDialogCommandFingerprint.exception }
/** /**
* Hides premium promotion popup * Hides premium promotion popup
*/ */
FloatingLayoutFingerprint.result?.let { FloatingLayoutFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val targetIndex = getWideLiteralInstructionIndex(FloatingLayout) + 2 val targetIndex = getWideLiteralInstructionIndex(FloatingLayout) + 2
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
@ -140,12 +140,12 @@ object GeneralAdsPatch : BaseBytecodePatch(
"invoke-static {v$targetRegister}, $PREMIUM_PROMOTION_POP_UP_CLASS_DESCRIPTOR->hidePremiumPromotion(Landroid/view/View;)V" "invoke-static {v$targetRegister}, $PREMIUM_PROMOTION_POP_UP_CLASS_DESCRIPTOR->hidePremiumPromotion(Landroid/view/View;)V"
) )
} }
} ?: throw FloatingLayoutFingerprint.exception }
/** /**
* Hides premium renewal banner * Hides premium renewal banner
*/ */
NotifierShelfFingerprint.result?.let { NotifierShelfFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val linearLayoutIndex = getWideLiteralInstructionIndex(ButtonContainer) + 3 val linearLayoutIndex = getWideLiteralInstructionIndex(ButtonContainer) + 3
val linearLayoutRegister = val linearLayoutRegister =
@ -156,7 +156,7 @@ object GeneralAdsPatch : BaseBytecodePatch(
"invoke-static {v$linearLayoutRegister}, $PREMIUM_PROMOTION_BANNER_CLASS_DESCRIPTOR->hidePremiumRenewal(Landroid/widget/LinearLayout;)V" "invoke-static {v$linearLayoutRegister}, $PREMIUM_PROMOTION_BANNER_CLASS_DESCRIPTOR->hidePremiumRenewal(Landroid/widget/LinearLayout;)V"
) )
} }
} ?: throw NotifierShelfFingerprint.exception }
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.ADS, CategoryType.ADS,

View File

@ -8,9 +8,9 @@ import app.revanced.patches.music.utils.integrations.Constants.FLYOUT_CLASS_DESC
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getWalkerMethod import app.revanced.util.getWalkerMethod
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
@Suppress("unused") @Suppress("unused")
object CompactDialogPatch : BaseBytecodePatch( object CompactDialogPatch : BaseBytecodePatch(
@ -24,7 +24,7 @@ object CompactDialogPatch : BaseBytecodePatch(
fingerprints = setOf(DialogSolidFingerprint) fingerprints = setOf(DialogSolidFingerprint)
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
DialogSolidFingerprint.result?.let { DialogSolidFingerprint.resultOrThrow().let {
val walkerMethod = it.getWalkerMethod(context, it.scanResult.patternScanResult!!.endIndex) val walkerMethod = it.getWalkerMethod(context, it.scanResult.patternScanResult!!.endIndex)
walkerMethod.addInstructions( walkerMethod.addInstructions(
2, """ 2, """
@ -32,7 +32,7 @@ object CompactDialogPatch : BaseBytecodePatch(
move-result p0 move-result p0
""" """
) )
} ?: throw DialogSolidFingerprint.exception }
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.FLYOUT, CategoryType.FLYOUT,

View File

@ -14,10 +14,10 @@ import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.EndButt
import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.patches.shared.litho.LithoFilterPatch import app.revanced.patches.shared.litho.LithoFilterPatch
import app.revanced.util.exception
import app.revanced.util.getTargetIndex import app.revanced.util.getTargetIndex
import app.revanced.util.getWideLiteralInstructionIndex import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -43,7 +43,7 @@ object FlyoutPanelPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
FlyoutPanelMenuItemPatch.hideComponents() FlyoutPanelMenuItemPatch.hideComponents()
EndButtonsContainerFingerprint.result?.let { EndButtonsContainerFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val startIndex = getWideLiteralInstructionIndex(EndButtonsContainer) val startIndex = getWideLiteralInstructionIndex(EndButtonsContainer)
val targetIndex = getTargetIndex(startIndex, Opcode.MOVE_RESULT_OBJECT) val targetIndex = getTargetIndex(startIndex, Opcode.MOVE_RESULT_OBJECT)
@ -54,7 +54,7 @@ object FlyoutPanelPatch : BaseBytecodePatch(
"invoke-static {v$targetRegister}, $FLYOUT_CLASS_DESCRIPTOR->hideLikeDislikeContainer(Landroid/view/View;)V" "invoke-static {v$targetRegister}, $FLYOUT_CLASS_DESCRIPTOR->hideLikeDislikeContainer(Landroid/view/View;)V"
) )
} }
} ?: throw EndButtonsContainerFingerprint.exception }
/** /**
* Forces sleep timer menu to be enabled. * Forces sleep timer menu to be enabled.

View File

@ -11,9 +11,9 @@ import app.revanced.patches.music.utils.overridespeed.OverrideSpeedHookPatch
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getTargetIndexWithMethodReferenceName import app.revanced.util.getTargetIndexWithMethodReferenceName
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
@Suppress("unused") @Suppress("unused")
@ -33,7 +33,7 @@ object ReplaceReportPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
FlyoutPanelMenuItemPatch.replaceComponents() FlyoutPanelMenuItemPatch.replaceComponents()
TouchOutsideFingerprint.result?.let { TouchOutsideFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val setOnClickListenerIndex = getTargetIndexWithMethodReferenceName("setOnClickListener") val setOnClickListenerIndex = getTargetIndexWithMethodReferenceName("setOnClickListener")
val setOnClickListenerRegister = getInstruction<FiveRegisterInstruction>(setOnClickListenerIndex).registerC val setOnClickListenerRegister = getInstruction<FiveRegisterInstruction>(setOnClickListenerIndex).registerC
@ -43,7 +43,7 @@ object ReplaceReportPatch : BaseBytecodePatch(
"sput-object v$setOnClickListenerRegister, $FLYOUT_CLASS_DESCRIPTOR->touchOutSideView:Landroid/view/View;" "sput-object v$setOnClickListenerRegister, $FLYOUT_CLASS_DESCRIPTOR->touchOutSideView:Landroid/view/View;"
) )
} }
} ?: throw TouchOutsideFingerprint.exception }
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.FLYOUT, CategoryType.FLYOUT,

View File

@ -9,9 +9,9 @@ import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.music.flyoutpanel.shared.fingerprints.MenuItemFingerprint import app.revanced.patches.music.flyoutpanel.shared.fingerprints.MenuItemFingerprint
import app.revanced.patches.music.utils.integrations.Constants.FLYOUT_CLASS_DESCRIPTOR import app.revanced.patches.music.utils.integrations.Constants.FLYOUT_CLASS_DESCRIPTOR
import app.revanced.util.exception
import app.revanced.util.getTargetIndex import app.revanced.util.getTargetIndex
import app.revanced.util.indexOfFirstInstruction import app.revanced.util.indexOfFirstInstruction
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
@ -28,7 +28,7 @@ object FlyoutPanelMenuItemPatch : BytecodePatch(
private var instructionAdded = false private var instructionAdded = false
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
MenuItemFingerprint.result?.let { MenuItemFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val freeIndex = getTargetIndex(Opcode.OR_INT_LIT16) val freeIndex = getTargetIndex(Opcode.OR_INT_LIT16)
val textViewIndex = it.scanResult.patternScanResult!!.startIndex val textViewIndex = it.scanResult.patternScanResult!!.startIndex
@ -43,7 +43,7 @@ object FlyoutPanelMenuItemPatch : BytecodePatch(
menuItemMethod = this menuItemMethod = this
} }
} ?: throw MenuItemFingerprint.exception }
} }
private fun MutableMethod.getEnumIndex() = indexOfFirstInstruction { private fun MutableMethod.getEnumIndex() = indexOfFirstInstruction {

View File

@ -13,9 +13,9 @@ import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.PlayerOverlayChip import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.PlayerOverlayChip
import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getWideLiteralInstructionIndex import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Suppress("unused") @Suppress("unused")
@ -37,7 +37,7 @@ object CastButtonPatch : BaseBytecodePatch(
/** /**
* Hide cast button * Hide cast button
*/ */
MediaRouteButtonFingerprint.result?.let { MediaRouteButtonFingerprint.resultOrThrow().let {
val setVisibilityMethod = val setVisibilityMethod =
it.mutableClass.methods.find { method -> method.name == "setVisibility" } it.mutableClass.methods.find { method -> method.name == "setVisibility" }
@ -49,12 +49,12 @@ object CastButtonPatch : BaseBytecodePatch(
""" """
) )
} ?: throw PatchException("Failed to find setVisibility method") } ?: throw PatchException("Failed to find setVisibility method")
} ?: throw MediaRouteButtonFingerprint.exception }
/** /**
* Hide floating cast banner * Hide floating cast banner
*/ */
PlayerOverlayChipFingerprint.result?.let { PlayerOverlayChipFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val targetIndex = getWideLiteralInstructionIndex(PlayerOverlayChip) + 2 val targetIndex = getWideLiteralInstructionIndex(PlayerOverlayChip) + 2
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
@ -64,7 +64,7 @@ object CastButtonPatch : BaseBytecodePatch(
"invoke-static {v$targetRegister}, $GENERAL_CLASS_DESCRIPTOR->hideCastButton(Landroid/view/View;)V" "invoke-static {v$targetRegister}, $GENERAL_CLASS_DESCRIPTOR->hideCastButton(Landroid/view/View;)V"
) )
} }
} ?: throw PlayerOverlayChipFingerprint.exception }
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.GENERAL, CategoryType.GENERAL,

View File

@ -9,8 +9,8 @@ import app.revanced.patches.music.utils.integrations.Constants.GENERAL_CLASS_DES
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Suppress("unused") @Suppress("unused")
@ -25,7 +25,7 @@ object CategoryBarPatch : BaseBytecodePatch(
fingerprints = setOf(ChipCloudFingerprint) fingerprints = setOf(ChipCloudFingerprint)
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
ChipCloudFingerprint.result?.let { ChipCloudFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.endIndex val targetIndex = it.scanResult.patternScanResult!!.endIndex
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
@ -35,7 +35,7 @@ object CategoryBarPatch : BaseBytecodePatch(
"invoke-static { v$targetRegister }, $GENERAL_CLASS_DESCRIPTOR->hideCategoryBar(Landroid/view/View;)V" "invoke-static { v$targetRegister }, $GENERAL_CLASS_DESCRIPTOR->hideCategoryBar(Landroid/view/View;)V"
) )
} }
} ?: throw ChipCloudFingerprint.exception }
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.GENERAL, CategoryType.GENERAL,

View File

@ -11,8 +11,8 @@ import app.revanced.patches.music.utils.integrations.Constants.GENERAL_CLASS_DES
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
@Suppress("unused") @Suppress("unused")
object FloatingButtonPatch : BaseBytecodePatch( object FloatingButtonPatch : BaseBytecodePatch(
@ -27,13 +27,13 @@ object FloatingButtonPatch : BaseBytecodePatch(
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
FloatingButtonParentFingerprint.result?.let { parentResult -> FloatingButtonParentFingerprint.resultOrThrow().let { parentResult ->
FloatingButtonFingerprint.also { FloatingButtonFingerprint.also {
it.resolve( it.resolve(
context, context,
parentResult.classDef parentResult.classDef
) )
}.result?.let { }.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
addInstructionsWithLabels( addInstructionsWithLabels(
1, """ 1, """
@ -44,8 +44,8 @@ object FloatingButtonPatch : BaseBytecodePatch(
""", ExternalLabel("show", getInstruction(1)) """, ExternalLabel("show", getInstruction(1))
) )
} }
} ?: throw FloatingButtonFingerprint.exception }
} ?: throw FloatingButtonParentFingerprint.exception }
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.GENERAL, CategoryType.GENERAL,

View File

@ -10,8 +10,8 @@ import app.revanced.patches.music.utils.integrations.Constants.GENERAL_CLASS_DES
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
@Suppress("unused") @Suppress("unused")
@ -34,7 +34,7 @@ object HistoryButtonPatch : BaseBytecodePatch(
HistoryMenuItemFingerprint, HistoryMenuItemFingerprint,
HistoryMenuItemOfflineTabFingerprint HistoryMenuItemOfflineTabFingerprint
).forEach { fingerprint -> ).forEach { fingerprint ->
fingerprint.result?.let { fingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.startIndex val insertIndex = it.scanResult.patternScanResult!!.startIndex
val insertRegister = getInstruction<FiveRegisterInstruction>(insertIndex).registerD val insertRegister = getInstruction<FiveRegisterInstruction>(insertIndex).registerD
@ -46,7 +46,7 @@ object HistoryButtonPatch : BaseBytecodePatch(
""" """
) )
} }
} ?: throw fingerprint.exception }
} }
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(

View File

@ -9,8 +9,8 @@ import app.revanced.patches.music.utils.integrations.Constants.GENERAL_CLASS_DES
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Suppress("unused") @Suppress("unused")
@ -25,7 +25,7 @@ object LandScapeModePatch : BaseBytecodePatch(
fingerprints = setOf(TabletIdentifierFingerprint) fingerprints = setOf(TabletIdentifierFingerprint)
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
TabletIdentifierFingerprint.result?.let { TabletIdentifierFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.endIndex val targetIndex = it.scanResult.patternScanResult!!.endIndex
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
@ -37,7 +37,7 @@ object LandScapeModePatch : BaseBytecodePatch(
""" """
) )
} }
} ?: throw TabletIdentifierFingerprint.exception }
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.GENERAL, CategoryType.GENERAL,

View File

@ -8,10 +8,10 @@ import app.revanced.patches.music.utils.integrations.Constants.COMPATIBLE_PACKAG
import app.revanced.patches.music.utils.integrations.Constants.GENERAL_CLASS_DESCRIPTOR import app.revanced.patches.music.utils.integrations.Constants.GENERAL_CLASS_DESCRIPTOR
import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getStringInstructionIndex import app.revanced.util.getStringInstructionIndex
import app.revanced.util.getTargetIndexReversed import app.revanced.util.getTargetIndexReversed
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
@ -25,7 +25,7 @@ object OldStyleLibraryShelfPatch : BaseBytecodePatch(
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
BrowseIdFingerprint.result?.let { BrowseIdFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val stringIndex = getStringInstructionIndex("FEmusic_offline") val stringIndex = getStringInstructionIndex("FEmusic_offline")
val targetIndex = getTargetIndexReversed(stringIndex, Opcode.IGET_OBJECT) val targetIndex = getTargetIndexReversed(stringIndex, Opcode.IGET_OBJECT)
@ -38,7 +38,7 @@ object OldStyleLibraryShelfPatch : BaseBytecodePatch(
""" """
) )
} }
} ?: throw BrowseIdFingerprint.exception }
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.GENERAL, CategoryType.GENERAL,

View File

@ -11,13 +11,13 @@ import app.revanced.patches.music.utils.integrations.Constants.COMPATIBLE_PACKAG
import app.revanced.patches.music.utils.integrations.Constants.GENERAL_CLASS_DESCRIPTOR import app.revanced.patches.music.utils.integrations.Constants.GENERAL_CLASS_DESCRIPTOR
import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getStringInstructionIndex import app.revanced.util.getStringInstructionIndex
import app.revanced.util.getTargetIndexReversed import app.revanced.util.getTargetIndexReversed
import app.revanced.util.getTargetIndexWithReference import app.revanced.util.getTargetIndexWithReference
import app.revanced.util.getWalkerMethod import app.revanced.util.getWalkerMethod
import app.revanced.util.indexOfFirstInstruction import app.revanced.util.indexOfFirstInstruction
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
@ -39,7 +39,7 @@ object DislikeRedirectionPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
PendingIntentReceiverFingerprint.result?.let { PendingIntentReceiverFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val startIndex = getStringInstructionIndex("YTM Dislike") val startIndex = getStringInstructionIndex("YTM Dislike")
val onClickRelayIndex = getTargetIndexReversed(startIndex, Opcode.INVOKE_VIRTUAL) val onClickRelayIndex = getTargetIndexReversed(startIndex, Opcode.INVOKE_VIRTUAL)
@ -63,14 +63,14 @@ object DislikeRedirectionPatch : BaseBytecodePatch(
} }
} }
} }
} ?: throw PendingIntentReceiverFingerprint.exception }
DislikeButtonOnClickListenerFingerprint.result?.let { DislikeButtonOnClickListenerFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val onClickIndex = getTargetIndexWithReference(onClickReference.toString()) val onClickIndex = getTargetIndexWithReference(onClickReference.toString())
injectCall(onClickIndex) injectCall(onClickIndex)
} }
} ?: throw DislikeButtonOnClickListenerFingerprint.exception }
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.GENERAL, CategoryType.GENERAL,

View File

@ -11,8 +11,8 @@ import app.revanced.patches.music.utils.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.patches.music.utils.settings.SettingsPatch.contexts import app.revanced.patches.music.utils.settings.SettingsPatch.contexts
import app.revanced.util.copyXmlNode import app.revanced.util.copyXmlNode
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Suppress("unused") @Suppress("unused")
@ -25,7 +25,7 @@ object ChangeStartPagePatch : BaseBytecodePatch(
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
ColdStartUpFingerprint.result?.let { ColdStartUpFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.endIndex val targetIndex = it.scanResult.patternScanResult!!.endIndex
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
@ -39,7 +39,7 @@ object ChangeStartPagePatch : BaseBytecodePatch(
) )
removeInstruction(targetIndex) removeInstruction(targetIndex)
} }
} ?: throw ColdStartUpFingerprint.exception }
/** /**
* Copy arrays * Copy arrays

View File

@ -9,8 +9,8 @@ import app.revanced.patches.music.utils.integrations.Constants.COMPATIBLE_PACKAG
import app.revanced.patches.music.utils.integrations.Constants.GENERAL_CLASS_DESCRIPTOR import app.revanced.patches.music.utils.integrations.Constants.GENERAL_CLASS_DESCRIPTOR
import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
@Suppress("unused") @Suppress("unused")
object TapToUpdateButtonPatch : BaseBytecodePatch( object TapToUpdateButtonPatch : BaseBytecodePatch(
@ -22,7 +22,7 @@ object TapToUpdateButtonPatch : BaseBytecodePatch(
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
ContentPillInFingerprint.result?.let { ContentPillInFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
addInstructionsWithLabels( addInstructionsWithLabels(
0, 0,
@ -34,7 +34,7 @@ object TapToUpdateButtonPatch : BaseBytecodePatch(
""", ExternalLabel("show", getInstruction(0)) """, ExternalLabel("show", getInstruction(0))
) )
} }
} ?: throw ContentPillInFingerprint.exception }
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.GENERAL, CategoryType.GENERAL,

View File

@ -5,8 +5,8 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patches.music.general.tooltip.fingerprints.TooltipContentViewFingerprint import app.revanced.patches.music.general.tooltip.fingerprints.TooltipContentViewFingerprint
import app.revanced.patches.music.utils.integrations.Constants.COMPATIBLE_PACKAGE import app.revanced.patches.music.utils.integrations.Constants.COMPATIBLE_PACKAGE
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
@Suppress("unused") @Suppress("unused")
object TooltipContentViewPatch : BaseBytecodePatch( object TooltipContentViewPatch : BaseBytecodePatch(
@ -18,10 +18,10 @@ object TooltipContentViewPatch : BaseBytecodePatch(
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
TooltipContentViewFingerprint.result?.mutableMethod?.addInstruction( TooltipContentViewFingerprint.resultOrThrow().mutableMethod.addInstruction(
0, 0,
"return-void" "return-void"
) ?: throw TooltipContentViewFingerprint.exception )
} }
} }

View File

@ -9,7 +9,7 @@ import app.revanced.patches.music.layout.overlayfilter.fingerprints.DesignBottom
import app.revanced.patches.music.utils.integrations.Constants.GENERAL_CLASS_DESCRIPTOR import app.revanced.patches.music.utils.integrations.Constants.GENERAL_CLASS_DESCRIPTOR
import app.revanced.patches.music.utils.integrations.IntegrationsPatch import app.revanced.patches.music.utils.integrations.IntegrationsPatch
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch
import app.revanced.util.exception import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Patch( @Patch(
@ -24,7 +24,7 @@ object OverlayFilterBytecodePatch : BytecodePatch(
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
DesignBottomSheetDialogFingerprint.result?.let { DesignBottomSheetDialogFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.endIndex - 1 val insertIndex = it.scanResult.patternScanResult!!.endIndex - 1
val freeRegister = getInstruction<OneRegisterInstruction>(insertIndex + 1).registerA val freeRegister = getInstruction<OneRegisterInstruction>(insertIndex + 1).registerA
@ -37,7 +37,7 @@ object OverlayFilterBytecodePatch : BytecodePatch(
""" """
) )
} }
} ?: throw DesignBottomSheetDialogFingerprint.exception }
} }
} }

View File

@ -4,8 +4,8 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patches.music.misc.backgroundplay.fingerprints.BackgroundPlaybackFingerprint import app.revanced.patches.music.misc.backgroundplay.fingerprints.BackgroundPlaybackFingerprint
import app.revanced.patches.music.utils.integrations.Constants.COMPATIBLE_PACKAGE import app.revanced.patches.music.utils.integrations.Constants.COMPATIBLE_PACKAGE
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
@Suppress("unused") @Suppress("unused")
object BackgroundPlayPatch : BaseBytecodePatch( object BackgroundPlayPatch : BaseBytecodePatch(
@ -16,7 +16,7 @@ object BackgroundPlayPatch : BaseBytecodePatch(
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
BackgroundPlaybackFingerprint.result?.let { BackgroundPlaybackFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
addInstructions( addInstructions(
0, """ 0, """
@ -25,7 +25,7 @@ object BackgroundPlayPatch : BaseBytecodePatch(
""" """
) )
} }
} ?: throw BackgroundPlaybackFingerprint.exception }
} }
} }

View File

@ -10,6 +10,8 @@ object BitrateDefaultValuePatch : BaseResourcePatch(
description = "Sets the audio quality to \"Always High\" when you first install the app.", description = "Sets the audio quality to \"Always High\" when you first install the app.",
compatiblePackages = COMPATIBLE_PACKAGE compatiblePackages = COMPATIBLE_PACKAGE
) { ) {
private const val RESOURCE_FILE_PATH = "res/xml/data_saving_settings.xml"
override fun execute(context: ResourceContext) { override fun execute(context: ResourceContext) {
context.xmlEditor[RESOURCE_FILE_PATH].use { editor -> context.xmlEditor[RESOURCE_FILE_PATH].use { editor ->
editor.file.getElementsByTagName("com.google.android.apps.youtube.music.ui.preference.PreferenceCategoryCompat") editor.file.getElementsByTagName("com.google.android.apps.youtube.music.ui.preference.PreferenceCategoryCompat")
@ -29,8 +31,5 @@ object BitrateDefaultValuePatch : BaseResourcePatch(
} }
} }
} }
} }
private const val RESOURCE_FILE_PATH = "res/xml/data_saving_settings.xml"
} }

View File

@ -8,10 +8,10 @@ import app.revanced.patches.music.misc.exclusiveaudio.fingerprints.DataSavingSet
import app.revanced.patches.music.misc.exclusiveaudio.fingerprints.MusicBrowserServiceFingerprint import app.revanced.patches.music.misc.exclusiveaudio.fingerprints.MusicBrowserServiceFingerprint
import app.revanced.patches.music.misc.exclusiveaudio.fingerprints.PodCastConfigFingerprint import app.revanced.patches.music.misc.exclusiveaudio.fingerprints.PodCastConfigFingerprint
import app.revanced.patches.music.utils.integrations.Constants.COMPATIBLE_PACKAGE import app.revanced.patches.music.utils.integrations.Constants.COMPATIBLE_PACKAGE
import app.revanced.util.exception
import app.revanced.util.getStringInstructionIndex import app.revanced.util.getStringInstructionIndex
import app.revanced.util.getWalkerMethod import app.revanced.util.getWalkerMethod
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -33,7 +33,7 @@ object ExclusiveAudioPatch : BaseBytecodePatch(
/** /**
* Don't play music videos * Don't play music videos
*/ */
MusicBrowserServiceFingerprint.result?.let { MusicBrowserServiceFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val targetIndex = val targetIndex =
getStringInstructionIndex("MBS: Return empty root for client: %s, isFullMediaBrowserEnabled: %b, is client browsable: %b, isRedAccount: %b") getStringInstructionIndex("MBS: Return empty root for client: %s, isFullMediaBrowserEnabled: %b, is client browsable: %b, isRedAccount: %b")
@ -56,12 +56,12 @@ object ExclusiveAudioPatch : BaseBytecodePatch(
break break
} }
} }
} ?: throw MusicBrowserServiceFingerprint.exception }
/** /**
* Don't play podcast videos * Don't play podcast videos
*/ */
PodCastConfigFingerprint.result?.let { PodCastConfigFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val insertIndex = implementation!!.instructions.size - 1 val insertIndex = implementation!!.instructions.size - 1
val targetRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA val targetRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
@ -71,9 +71,9 @@ object ExclusiveAudioPatch : BaseBytecodePatch(
"const/4 v$targetRegister, 0x1" "const/4 v$targetRegister, 0x1"
) )
} }
} ?: throw PodCastConfigFingerprint.exception }
DataSavingSettingsFragmentFingerprint.result?.let { DataSavingSettingsFragmentFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val insertIndex = getStringInstructionIndex("pref_key_dont_play_nma_video") + 4 val insertIndex = getStringInstructionIndex("pref_key_dont_play_nma_video") + 4
val targetRegister = getInstruction<FiveRegisterInstruction>(insertIndex).registerD val targetRegister = getInstruction<FiveRegisterInstruction>(insertIndex).registerD
@ -83,6 +83,6 @@ object ExclusiveAudioPatch : BaseBytecodePatch(
"const/4 v$targetRegister, 0x1" "const/4 v$targetRegister, 0x1"
) )
} }
} ?: throw DataSavingSettingsFragmentFingerprint.exception }
} }
} }

View File

@ -4,8 +4,8 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patches.music.misc.minimizedplayback.fingerprints.MinimizedPlaybackManagerFingerprint import app.revanced.patches.music.misc.minimizedplayback.fingerprints.MinimizedPlaybackManagerFingerprint
import app.revanced.patches.music.utils.integrations.Constants.COMPATIBLE_PACKAGE import app.revanced.patches.music.utils.integrations.Constants.COMPATIBLE_PACKAGE
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
@Suppress("unused") @Suppress("unused")
object MinimizedPlaybackPatch : BaseBytecodePatch( object MinimizedPlaybackPatch : BaseBytecodePatch(
@ -16,9 +16,9 @@ object MinimizedPlaybackPatch : BaseBytecodePatch(
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
MinimizedPlaybackManagerFingerprint.result?.mutableMethod?.addInstruction( MinimizedPlaybackManagerFingerprint.resultOrThrow().mutableMethod.addInstruction(
0, "return-void" 0, "return-void"
) ?: throw MinimizedPlaybackManagerFingerprint.exception )
} }
} }

View File

@ -12,12 +12,12 @@ import app.revanced.patches.music.navigation.component.NavigationBarComponentPat
import app.revanced.patches.music.utils.integrations.Constants.COMPATIBLE_PACKAGE import app.revanced.patches.music.utils.integrations.Constants.COMPATIBLE_PACKAGE
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.PrivacyTosFooter import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.PrivacyTosFooter
import app.revanced.util.exception
import app.revanced.util.getTargetIndex import app.revanced.util.getTargetIndex
import app.revanced.util.getTargetIndexWithReference import app.revanced.util.getTargetIndexWithReference
import app.revanced.util.getWalkerMethod import app.revanced.util.getWalkerMethod
import app.revanced.util.getWideLiteralInstructionIndex import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
@ -41,7 +41,7 @@ object GetPremiumPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
// Hides get premium button at the bottom of the account switching menu // Hides get premium button at the bottom of the account switching menu
HideGetPremiumFingerprint.result?.let { HideGetPremiumFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.startIndex val insertIndex = it.scanResult.patternScanResult!!.startIndex
val register = getInstruction<TwoRegisterInstruction>(insertIndex).registerA val register = getInstruction<TwoRegisterInstruction>(insertIndex).registerA
@ -51,10 +51,10 @@ object GetPremiumPatch : BaseBytecodePatch(
"const/4 v$register, 0x0" "const/4 v$register, 0x0"
) )
} }
} ?: throw HideGetPremiumFingerprint.exception }
// Hides get premium button at the top of the account switching menu // Hides get premium button at the top of the account switching menu
AccountMenuFooterFingerprint.result?.let { AccountMenuFooterFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val constIndex = getWideLiteralInstructionIndex(PrivacyTosFooter) val constIndex = getWideLiteralInstructionIndex(PrivacyTosFooter)
val walkerIndex = getTargetIndex(constIndex + 2, Opcode.INVOKE_VIRTUAL) val walkerIndex = getTargetIndex(constIndex + 2, Opcode.INVOKE_VIRTUAL)
@ -73,18 +73,18 @@ object GetPremiumPatch : BaseBytecodePatch(
) )
} }
} }
} ?: throw AccountMenuFooterFingerprint.exception }
// Hides premium membership menu in settings // Hides premium membership menu in settings
MembershipSettingsParentFingerprint.result?.classDef?.let { classDef -> MembershipSettingsParentFingerprint.resultOrThrow().classDef.let { classDef ->
MembershipSettingsFingerprint.resolve(context, classDef) MembershipSettingsFingerprint.resolve(context, classDef)
MembershipSettingsFingerprint.result?.mutableMethod?.addInstructions( MembershipSettingsFingerprint.resultOrThrow().mutableMethod.addInstructions(
0, """ 0, """
const/4 v0, 0x0 const/4 v0, 0x0
return-object v0 return-object v0
""" """
) ?: throw MembershipSettingsFingerprint.exception )
} ?: throw MembershipSettingsParentFingerprint.exception }
} }
} }

View File

@ -9,10 +9,10 @@ import app.revanced.patches.music.misc.tastebuilder.fingerprints.TasteBuilderSyn
import app.revanced.patches.music.utils.integrations.Constants.COMPATIBLE_PACKAGE import app.revanced.patches.music.utils.integrations.Constants.COMPATIBLE_PACKAGE
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.MusicTasteBuilderShelf import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.MusicTasteBuilderShelf
import app.revanced.util.exception
import app.revanced.util.getTargetIndex import app.revanced.util.getTargetIndex
import app.revanced.util.getWideLiteralInstructionIndex import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -25,7 +25,7 @@ object TasteBuilderPatch : BaseBytecodePatch(
fingerprints = setOf(TasteBuilderConstructorFingerprint) fingerprints = setOf(TasteBuilderConstructorFingerprint)
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
TasteBuilderConstructorFingerprint.result?.let { parentResult -> TasteBuilderConstructorFingerprint.resultOrThrow().let { parentResult ->
TasteBuilderSyntheticFingerprint.resolve(context, parentResult.classDef) TasteBuilderSyntheticFingerprint.resolve(context, parentResult.classDef)
parentResult.mutableMethod.apply { parentResult.mutableMethod.apply {
@ -41,9 +41,9 @@ object TasteBuilderPatch : BaseBytecodePatch(
""" """
) )
} }
} ?: throw TasteBuilderConstructorFingerprint.exception }
TasteBuilderSyntheticFingerprint.result?.let { TasteBuilderSyntheticFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.startIndex val insertIndex = it.scanResult.patternScanResult!!.startIndex
val insertRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA val insertRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
@ -53,6 +53,6 @@ object TasteBuilderPatch : BaseBytecodePatch(
"const/4 v$insertRegister, 0x0" "const/4 v$insertRegister, 0x0"
) )
} }
} ?: throw TasteBuilderSyntheticFingerprint.exception }
} }
} }

View File

@ -9,8 +9,8 @@ import app.revanced.patches.music.utils.integrations.Constants.NAVIGATION_CLASS_
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Suppress("unused") @Suppress("unused")
@ -26,7 +26,7 @@ object BlackNavigationBarPatch : BaseBytecodePatch(
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
TabLayoutFingerprint.result?.let { TabLayoutFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.endIndex val targetIndex = it.scanResult.patternScanResult!!.endIndex
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
@ -38,7 +38,7 @@ object BlackNavigationBarPatch : BaseBytecodePatch(
""" """
) )
} }
} ?: throw TabLayoutFingerprint.exception }
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.NAVIGATION, CategoryType.NAVIGATION,

View File

@ -10,11 +10,11 @@ import app.revanced.patches.music.utils.integrations.Constants.NAVIGATION_CLASS_
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getTargetIndex import app.revanced.util.getTargetIndex
import app.revanced.util.getTargetIndexWithMethodReferenceName import app.revanced.util.getTargetIndexWithMethodReferenceName
import app.revanced.util.getWideLiteralInstructionIndex import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
@ -38,7 +38,7 @@ object NavigationBarComponentPatch : BaseBytecodePatch(
/** /**
* Hide navigation labels * Hide navigation labels
*/ */
TabLayoutTextFingerprint.result?.let { TabLayoutTextFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val constIndex = getWideLiteralInstructionIndex(SharedResourceIdPatch.Text1) val constIndex = getWideLiteralInstructionIndex(SharedResourceIdPatch.Text1)
val targetIndex = getTargetIndex(constIndex, Opcode.CHECK_CAST) val targetIndex = getTargetIndex(constIndex, Opcode.CHECK_CAST)
@ -53,7 +53,7 @@ object NavigationBarComponentPatch : BaseBytecodePatch(
"invoke-static {v$targetRegister}, $NAVIGATION_CLASS_DESCRIPTOR->hideNavigationLabel(Landroid/widget/TextView;)V" "invoke-static {v$targetRegister}, $NAVIGATION_CLASS_DESCRIPTOR->hideNavigationLabel(Landroid/widget/TextView;)V"
) )
} }
} ?: throw TabLayoutTextFingerprint.exception }
SettingsPatch.contexts.xmlEditor[RESOURCE_FILE_PATH].use { editor -> SettingsPatch.contexts.xmlEditor[RESOURCE_FILE_PATH].use { editor ->
val document = editor.file val document = editor.file
@ -71,7 +71,7 @@ object NavigationBarComponentPatch : BaseBytecodePatch(
/** /**
* Hide navigation bar & buttons * Hide navigation bar & buttons
*/ */
TabLayoutTextFingerprint.result?.let { TabLayoutTextFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val enumIndex = it.scanResult.patternScanResult!!.startIndex + 3 val enumIndex = it.scanResult.patternScanResult!!.startIndex + 3
val enumRegister = getInstruction<OneRegisterInstruction>(enumIndex).registerA val enumRegister = getInstruction<OneRegisterInstruction>(enumIndex).registerA
@ -90,7 +90,7 @@ object NavigationBarComponentPatch : BaseBytecodePatch(
"sput-object v$enumRegister, $NAVIGATION_CLASS_DESCRIPTOR->lastPivotTab:Ljava/lang/Enum;" "sput-object v$enumRegister, $NAVIGATION_CLASS_DESCRIPTOR->lastPivotTab:Ljava/lang/Enum;"
) )
} }
} ?: throw TabLayoutTextFingerprint.exception }
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.NAVIGATION, CategoryType.NAVIGATION,

View File

@ -13,11 +13,11 @@ import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.ColorGrey import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.ColorGrey
import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getTargetIndex import app.revanced.util.getTargetIndex
import app.revanced.util.getTargetIndexReversed import app.revanced.util.getTargetIndexReversed
import app.revanced.util.getWideLiteralInstructionIndex import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.MethodParameter import com.android.tools.smali.dexlib2.iface.MethodParameter
@ -43,11 +43,11 @@ object ColorMatchPlayerPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
MiniPlayerConstructorFingerprint.result?.let { parentResult -> MiniPlayerConstructorFingerprint.resultOrThrow().let { parentResult ->
// Resolves fingerprints // Resolves fingerprints
SwitchToggleColorFingerprint.resolve(context, parentResult.classDef) SwitchToggleColorFingerprint.resolve(context, parentResult.classDef)
SwitchToggleColorFingerprint.result?.let { SwitchToggleColorFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
methodParameter = parameters methodParameter = parameters
@ -94,8 +94,8 @@ object ColorMatchPlayerPatch : BaseBytecodePatch(
removeInstruction(invokeDirectIndex) removeInstruction(invokeDirectIndex)
} }
} }
} ?: throw SwitchToggleColorFingerprint.exception }
} ?: throw MiniPlayerConstructorFingerprint.exception }
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.PLAYER, CategoryType.PLAYER,

View File

@ -8,8 +8,8 @@ import app.revanced.patches.music.utils.integrations.Constants.COMPATIBLE_PACKAG
import app.revanced.patches.music.utils.integrations.Constants.PLAYER_CLASS_DESCRIPTOR import app.revanced.patches.music.utils.integrations.Constants.PLAYER_CLASS_DESCRIPTOR
import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Suppress("unused") @Suppress("unused")
@ -22,7 +22,7 @@ object MinimizedPlayerPatch : BaseBytecodePatch(
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
MinimizedPlayerFingerprint.result?.let { MinimizedPlayerFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.endIndex val insertIndex = it.scanResult.patternScanResult!!.endIndex
val insertRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA val insertRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
@ -34,7 +34,7 @@ object MinimizedPlayerPatch : BaseBytecodePatch(
""" """
) )
} }
} ?: throw MinimizedPlayerFingerprint.exception }
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.PLAYER, CategoryType.PLAYER,

View File

@ -23,12 +23,12 @@ import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.TopEnd
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.TopStart import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.TopStart
import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getStringInstructionIndex import app.revanced.util.getStringInstructionIndex
import app.revanced.util.getTargetIndex import app.revanced.util.getTargetIndex
import app.revanced.util.getTargetIndexReversed import app.revanced.util.getTargetIndexReversed
import app.revanced.util.getWideLiteralInstructionIndex import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
@ -81,23 +81,20 @@ object MiniPlayerButtonPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
val miniPlayerConstructorMutableMethod = val miniPlayerConstructorMutableMethod =
MiniPlayerConstructorFingerprint.result?.mutableMethod MiniPlayerConstructorFingerprint.resultOrThrow().mutableMethod
?: throw MiniPlayerConstructorFingerprint.exception
val mppWatchWhileLayoutMutableMethod = val mppWatchWhileLayoutMutableMethod =
MppWatchWhileLayoutFingerprint.result?.mutableMethod MppWatchWhileLayoutFingerprint.resultOrThrow().mutableMethod
?: throw MppWatchWhileLayoutFingerprint.exception
val pendingIntentReceiverMutableMethod = val pendingIntentReceiverMutableMethod =
PendingIntentReceiverFingerprint.result?.mutableMethod PendingIntentReceiverFingerprint.resultOrThrow().mutableMethod
?: throw PendingIntentReceiverFingerprint.exception
if (!SettingsPatch.upward0642) { if (!SettingsPatch.upward0642) {
MiniPlayerParentFingerprint.result?.let { parentResult -> MiniPlayerParentFingerprint.resultOrThrow().let { parentResult ->
// Resolves fingerprints // Resolves fingerprints
NextButtonVisibilityFingerprint.resolve(context, parentResult.classDef) NextButtonVisibilityFingerprint.resolve(context, parentResult.classDef)
NextButtonVisibilityFingerprint.result?.let { NextButtonVisibilityFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.startIndex + 1 val targetIndex = it.scanResult.patternScanResult!!.startIndex + 1
val targetRegister = val targetRegister =
@ -110,8 +107,8 @@ object MiniPlayerButtonPatch : BaseBytecodePatch(
""" """
) )
} }
} ?: throw NextButtonVisibilityFingerprint.exception }
} ?: throw MiniPlayerParentFingerprint.exception }
} else { } else {
miniPlayerConstructorMutableMethod.setInstanceFieldValue(NEXT_BUTTON_METHOD_NAME, TopStart) miniPlayerConstructorMutableMethod.setInstanceFieldValue(NEXT_BUTTON_METHOD_NAME, TopStart)
mppWatchWhileLayoutMutableMethod.setStaticFieldValue(NEXT_BUTTON_FIELD_NAME, TopStart) mppWatchWhileLayoutMutableMethod.setStaticFieldValue(NEXT_BUTTON_FIELD_NAME, TopStart)
@ -210,7 +207,7 @@ object MiniPlayerButtonPatch : BaseBytecodePatch(
) )
} ?: throw PatchException("onClickClass not found!") } ?: throw PatchException("onClickClass not found!")
PlayerPatchConstructorFingerprint.result?.let { PlayerPatchConstructorFingerprint.resultOrThrow().let {
val mutableClass = it.mutableClass val mutableClass = it.mutableClass
mutableClass.methods.find { method -> method.name == methodName } mutableClass.methods.find { method -> method.name == methodName }
?.apply { ?.apply {
@ -227,14 +224,14 @@ object MiniPlayerButtonPatch : BaseBytecodePatch(
) )
addInstructionsWithLabels( addInstructionsWithLabels(
0, """ 0, """
sget-object v0, $PLAYER_CLASS_DESCRIPTOR->$fieldName:$onClickReferenceDefiningClass sget-object v0, $PLAYER_CLASS_DESCRIPTOR->$fieldName:$onClickReferenceDefiningClass
if-eqz v0, :ignore if-eqz v0, :ignore
invoke-virtual {v0}, $onClickReference invoke-virtual {v0}, $onClickReference
:ignore :ignore
return-void return-void
""" """
) )
} }
} ?: throw PlayerPatchConstructorFingerprint.exception }
} }
} }

View File

@ -8,8 +8,8 @@ import app.revanced.patches.music.utils.integrations.Constants.COMPATIBLE_PACKAG
import app.revanced.patches.music.utils.integrations.Constants.PLAYER_CLASS_DESCRIPTOR import app.revanced.patches.music.utils.integrations.Constants.PLAYER_CLASS_DESCRIPTOR
import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Suppress("unused") @Suppress("unused")
@ -21,7 +21,7 @@ object RememberRepeatPatch : BaseBytecodePatch(
fingerprints = setOf(RepeatTrackFingerprint) fingerprints = setOf(RepeatTrackFingerprint)
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
RepeatTrackFingerprint.result?.let { RepeatTrackFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.endIndex val targetIndex = it.scanResult.patternScanResult!!.endIndex
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
@ -33,7 +33,7 @@ object RememberRepeatPatch : BaseBytecodePatch(
""" """
) )
} }
} ?: throw RepeatTrackFingerprint.exception }
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.PLAYER, CategoryType.PLAYER,

View File

@ -19,9 +19,9 @@ import app.revanced.patches.music.utils.settings.SettingsPatch.contexts
import app.revanced.patches.music.utils.videotype.VideoTypeHookPatch import app.revanced.patches.music.utils.videotype.VideoTypeHookPatch
import app.revanced.util.ResourceGroup import app.revanced.util.ResourceGroup
import app.revanced.util.copyResources import app.revanced.util.copyResources
import app.revanced.util.exception
import app.revanced.util.getWideLiteralInstructionIndex import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
@ -46,7 +46,7 @@ object ReplaceCastButtonPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
CastButtonContainerFingerprint.resolve(context, mainActivityClassDef) CastButtonContainerFingerprint.resolve(context, mainActivityClassDef)
CastButtonContainerFingerprint.result?.let { CastButtonContainerFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val freeIndex = getWideLiteralInstructionIndex(PlayerCastMediaRouteButton) + 1 val freeIndex = getWideLiteralInstructionIndex(PlayerCastMediaRouteButton) + 1
val freeRegister = getInstruction<OneRegisterInstruction>(freeIndex).registerA val freeRegister = getInstruction<OneRegisterInstruction>(freeIndex).registerA
@ -82,7 +82,7 @@ object ReplaceCastButtonPatch : BaseBytecodePatch(
break break
} }
} }
} ?: throw CastButtonContainerFingerprint.exception }
PlayerResponsePatch.injectPlaylistCall( PlayerResponsePatch.injectPlaylistCall(
"$UTILS_PATH/CheckMusicVideoPatch;" + "$UTILS_PATH/CheckMusicVideoPatch;" +

View File

@ -9,8 +9,8 @@ import app.revanced.patches.music.utils.integrations.Constants.PLAYER_CLASS_DESC
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
@Suppress("unused") @Suppress("unused")
@ -25,7 +25,7 @@ object ShareButtonPatch : BaseBytecodePatch(
fingerprints = setOf(RemixGenericButtonFingerprint) fingerprints = setOf(RemixGenericButtonFingerprint)
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
RemixGenericButtonFingerprint.result?.let { RemixGenericButtonFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.endIndex val targetIndex = it.scanResult.patternScanResult!!.endIndex
val targetRegister = getInstruction<TwoRegisterInstruction>(targetIndex).registerA val targetRegister = getInstruction<TwoRegisterInstruction>(targetIndex).registerA
@ -37,7 +37,7 @@ object ShareButtonPatch : BaseBytecodePatch(
""" """
) )
} }
} ?: throw RemixGenericButtonFingerprint.exception }
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.PLAYER, CategoryType.PLAYER,

View File

@ -15,8 +15,8 @@ import app.revanced.patches.music.utils.integrations.Constants.COMPATIBLE_PACKAG
import app.revanced.patches.music.utils.integrations.Constants.PLAYER_CLASS_DESCRIPTOR import app.revanced.patches.music.utils.integrations.Constants.PLAYER_CLASS_DESCRIPTOR
import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import app.revanced.util.transformFields import app.revanced.util.transformFields
import app.revanced.util.traverseClassHierarchy import app.revanced.util.traverseClassHierarchy
import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.AccessFlags
@ -48,7 +48,7 @@ object RememberShufflePatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
ShuffleClassReferenceFingerprint.result?.let { ShuffleClassReferenceFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val startIndex = it.scanResult.patternScanResult!!.startIndex val startIndex = it.scanResult.patternScanResult!!.startIndex
val endIndex = it.scanResult.patternScanResult!!.endIndex val endIndex = it.scanResult.patternScanResult!!.endIndex
@ -110,9 +110,9 @@ object RememberShufflePatch : BaseBytecodePatch(
).toMutable() ).toMutable()
} }
} }
} ?: throw ShuffleClassReferenceFingerprint.exception }
MusicPlaybackControlsFingerprint.result?.let { MusicPlaybackControlsFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
addInstruction( addInstruction(
0, 0,
@ -158,7 +158,7 @@ object RememberShufflePatch : BaseBytecodePatch(
it.mutableClass.methods.add(shuffleMethod) it.mutableClass.methods.add(shuffleMethod)
it.mutableClass.staticFields.add(shuffleField) it.mutableClass.staticFields.add(shuffleField)
} }
} ?: throw MusicPlaybackControlsFingerprint.exception }
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.PLAYER, CategoryType.PLAYER,

View File

@ -19,7 +19,6 @@ import app.revanced.patches.music.utils.integrations.Constants.PLAYER_CLASS_DESC
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getReference import app.revanced.util.getReference
import app.revanced.util.getStringInstructionIndex import app.revanced.util.getStringInstructionIndex
import app.revanced.util.getTargetIndex import app.revanced.util.getTargetIndex
@ -27,6 +26,7 @@ import app.revanced.util.getTargetIndexReversed
import app.revanced.util.getTargetIndexWithFieldReferenceType import app.revanced.util.getTargetIndexWithFieldReferenceType
import app.revanced.util.getWideLiteralInstructionIndex import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -67,7 +67,7 @@ object SwipeToDismissMiniPlayerPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
if (!SettingsPatch.upward0642) { if (!SettingsPatch.upward0642) {
SwipeToCloseFingerprint.result?.let { SwipeToCloseFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val insertIndex = implementation!!.instructions.size - 1 val insertIndex = implementation!!.instructions.size - 1
val targetRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA val targetRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
@ -79,21 +79,21 @@ object SwipeToDismissMiniPlayerPatch : BaseBytecodePatch(
""" """
) )
} }
} ?: throw SwipeToCloseFingerprint.exception }
} else { } else {
// Dismiss mini player by swiping down // Dismiss mini player by swiping down
InteractionLoggingEnumFingerprint.result?.let { InteractionLoggingEnumFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val stringIndex = getStringInstructionIndex("INTERACTION_LOGGING_GESTURE_TYPE_SWIPE") val stringIndex = getStringInstructionIndex("INTERACTION_LOGGING_GESTURE_TYPE_SWIPE")
val sPutObjectIndex = getTargetIndex(stringIndex, Opcode.SPUT_OBJECT) val sPutObjectIndex = getTargetIndex(stringIndex, Opcode.SPUT_OBJECT)
sGetObjectReference = getInstruction<ReferenceInstruction>(sPutObjectIndex).reference sGetObjectReference = getInstruction<ReferenceInstruction>(sPutObjectIndex).reference
} }
} ?: throw InteractionLoggingEnumFingerprint.exception }
MusicActivityWidgetFingerprint.result?.let { MusicActivityWidgetFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
widgetIndex = getWideLiteralInstructionIndex(79500) widgetIndex = getWideLiteralInstructionIndex(79500)
@ -105,13 +105,13 @@ object SwipeToDismissMiniPlayerPatch : BaseBytecodePatch(
invokeDirectReference = getReference(Opcode.INVOKE_DIRECT, false) invokeDirectReference = getReference(Opcode.INVOKE_DIRECT, false)
invokeInterfaceSecondaryReference = getReference(Opcode.INVOKE_INTERFACE, false) invokeInterfaceSecondaryReference = getReference(Opcode.INVOKE_INTERFACE, false)
} }
} ?: throw MusicActivityWidgetFingerprint.exception }
HandleSearchRenderedFingerprint.result?.let { parentResult -> HandleSearchRenderedFingerprint.resultOrThrow().let { parentResult ->
// Resolves fingerprints // Resolves fingerprints
HandleSignInEventFingerprint.resolve(context, parentResult.classDef) HandleSignInEventFingerprint.resolve(context, parentResult.classDef)
HandleSignInEventFingerprint.result?.let { HandleSignInEventFingerprint.resultOrThrow().let {
val dismissBehaviorMethod = context.toMethodWalker(it.method) val dismissBehaviorMethod = context.toMethodWalker(it.method)
.nextMethod(it.scanResult.patternScanResult!!.startIndex, true) .nextMethod(it.scanResult.patternScanResult!!.startIndex, true)
.getMethod() as MutableMethod .getMethod() as MutableMethod
@ -145,14 +145,14 @@ object SwipeToDismissMiniPlayerPatch : BaseBytecodePatch(
""", ExternalLabel("dismiss", getInstruction(insertIndex)) """, ExternalLabel("dismiss", getInstruction(insertIndex))
) )
} }
} ?: throw HandleSignInEventFingerprint.exception }
} ?: throw HandleSearchRenderedFingerprint.exception }
// Endregion // Endregion
// Hides default text display when the app is cold started // Hides default text display when the app is cold started
MiniPlayerDefaultTextFingerprint.result?.let { MiniPlayerDefaultTextFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.endIndex val insertIndex = it.scanResult.patternScanResult!!.endIndex
val insertRegister = getInstruction<TwoRegisterInstruction>(insertIndex).registerB val insertRegister = getInstruction<TwoRegisterInstruction>(insertIndex).registerB
@ -164,13 +164,13 @@ object SwipeToDismissMiniPlayerPatch : BaseBytecodePatch(
""" """
) )
} }
} ?: throw MiniPlayerDefaultTextFingerprint.exception }
// Endregion // Endregion
// Hides default text display after dismissing the mini player // Hides default text display after dismissing the mini player
MiniPlayerDefaultViewVisibilityFingerprint.result?.let { MiniPlayerDefaultViewVisibilityFingerprint.resultOrThrow().let {
it.mutableClass.methods.find { method -> it.mutableClass.methods.find { method ->
method.parameters == listOf("Landroid/view/View;", "I") method.parameters == listOf("Landroid/view/View;", "I")
}?.apply { }?.apply {
@ -193,7 +193,7 @@ object SwipeToDismissMiniPlayerPatch : BaseBytecodePatch(
) )
} ?: throw PatchException("Could not find targetMethod") } ?: throw PatchException("Could not find targetMethod")
} ?: throw MiniPlayerDefaultViewVisibilityFingerprint.exception }
// Endregion // Endregion

View File

@ -12,10 +12,10 @@ import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.patches.music.utils.videotype.VideoTypeHookPatch import app.revanced.patches.music.utils.videotype.VideoTypeHookPatch
import app.revanced.util.exception
import app.revanced.util.getTargetIndex import app.revanced.util.getTargetIndex
import app.revanced.util.getWalkerMethod import app.revanced.util.getWalkerMethod
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -33,7 +33,7 @@ object ZenModePatch : BaseBytecodePatch(
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
MiniPlayerConstructorFingerprint.result?.let { parentResult -> MiniPlayerConstructorFingerprint.resultOrThrow().let { parentResult ->
// Resolves fingerprints // Resolves fingerprints
SwitchToggleColorFingerprint.resolve(context, parentResult.classDef) SwitchToggleColorFingerprint.resolve(context, parentResult.classDef)
ZenModeFingerprint.resolve(context, parentResult.classDef) ZenModeFingerprint.resolve(context, parentResult.classDef)
@ -56,7 +56,7 @@ object ZenModePatch : BaseBytecodePatch(
} }
} }
SwitchToggleColorFingerprint.result?.let { SwitchToggleColorFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val invokeDirectIndex = getTargetIndex(Opcode.INVOKE_DIRECT) val invokeDirectIndex = getTargetIndex(Opcode.INVOKE_DIRECT)
val walkerMethod = getWalkerMethod(context, invokeDirectIndex) val walkerMethod = getWalkerMethod(context, invokeDirectIndex)
@ -70,8 +70,8 @@ object ZenModePatch : BaseBytecodePatch(
""" """
) )
} }
} ?: throw SwitchToggleColorFingerprint.exception }
} ?: throw MiniPlayerConstructorFingerprint.exception }
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.PLAYER, CategoryType.PLAYER,

View File

@ -4,8 +4,8 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patches.music.utils.fix.androidauto.fingerprints.CertificateCheckFingerprint import app.revanced.patches.music.utils.fix.androidauto.fingerprints.CertificateCheckFingerprint
import app.revanced.patches.music.utils.integrations.Constants.COMPATIBLE_PACKAGE import app.revanced.patches.music.utils.integrations.Constants.COMPATIBLE_PACKAGE
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
@Suppress("unused") @Suppress("unused")
object AndroidAutoCertificatePatch : BaseBytecodePatch( object AndroidAutoCertificatePatch : BaseBytecodePatch(
@ -16,7 +16,7 @@ object AndroidAutoCertificatePatch : BaseBytecodePatch(
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
CertificateCheckFingerprint.result?.let { CertificateCheckFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
addInstructions( addInstructions(
0, """ 0, """
@ -25,7 +25,7 @@ object AndroidAutoCertificatePatch : BaseBytecodePatch(
""" """
) )
} }
} ?: throw CertificateCheckFingerprint.exception }
} }
} }

View File

@ -1,5 +1,5 @@
package app.revanced.patches.music.utils.fix.clientspoof package app.revanced.patches.music.utils.fix.clientspoof
import app.revanced.patches.shared.clientspoof.AbstractClientSpoofPatch import app.revanced.patches.shared.clientspoof.BaseClientSpoofPatch
object ClientSpoofPatch : AbstractClientSpoofPatch("com.google.android.apps.youtube.music") object ClientSpoofPatch : BaseClientSpoofPatch("com.google.android.apps.youtube.music")

View File

@ -8,7 +8,7 @@ import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.music.utils.fix.fileprovider.fingerprints.FileProviderResolverFingerprint import app.revanced.patches.music.utils.fix.fileprovider.fingerprints.FileProviderResolverFingerprint
import app.revanced.patches.shared.packagename.PackageNamePatch import app.revanced.patches.shared.packagename.PackageNamePatch
import app.revanced.util.exception import app.revanced.util.resultOrThrow
@Patch(dependencies = [PackageNamePatch::class]) @Patch(dependencies = [PackageNamePatch::class])
object FileProviderPatch : BytecodePatch( object FileProviderPatch : BytecodePatch(
@ -28,7 +28,7 @@ object FileProviderPatch : BytecodePatch(
* *
* To solve this issue, replace the package name of YouTube with YT Music's package name. * To solve this issue, replace the package name of YouTube with YT Music's package name.
*/ */
FileProviderResolverFingerprint.result?.let { FileProviderResolverFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
addInstructionsWithLabels( addInstructionsWithLabels(
0, """ 0, """
@ -40,7 +40,7 @@ object FileProviderPatch : BytecodePatch(
""", ExternalLabel("ignore", getInstruction(0)) """, ExternalLabel("ignore", getInstruction(0))
) )
} }
} ?: throw FileProviderResolverFingerprint.exception }
} }
} }

View File

@ -6,7 +6,7 @@ import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.music.utils.integrations.Constants.UTILS_PATH import app.revanced.patches.music.utils.integrations.Constants.UTILS_PATH
import app.revanced.patches.music.utils.mainactivity.fingerprints.MainActivityFingerprint import app.revanced.patches.music.utils.mainactivity.fingerprints.MainActivityFingerprint
import app.revanced.util.exception import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.ClassDef import com.android.tools.smali.dexlib2.iface.ClassDef
object MainActivityResolvePatch : BytecodePatch( object MainActivityResolvePatch : BytecodePatch(
@ -16,10 +16,10 @@ object MainActivityResolvePatch : BytecodePatch(
private lateinit var onCreateMethod: MutableMethod private lateinit var onCreateMethod: MutableMethod
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
MainActivityFingerprint.result?.let { MainActivityFingerprint.resultOrThrow().let {
mainActivityClassDef = it.classDef mainActivityClassDef = it.classDef
onCreateMethod = it.mutableMethod onCreateMethod = it.mutableMethod
} ?: throw MainActivityFingerprint.exception }
} }
fun injectInit( fun injectInit(

View File

@ -15,7 +15,7 @@ import app.revanced.patches.music.utils.overridequality.fingerprints.VideoQualit
import app.revanced.patches.music.utils.overridequality.fingerprints.VideoQualityPatchFingerprint import app.revanced.patches.music.utils.overridequality.fingerprints.VideoQualityPatchFingerprint
import app.revanced.patches.music.utils.overridequality.fingerprints.VideoQualityTextFingerprint import app.revanced.patches.music.utils.overridequality.fingerprints.VideoQualityTextFingerprint
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch
import app.revanced.util.exception import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
@ -41,7 +41,7 @@ object OverrideQualityHookPatch : BytecodePatch(
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
VideoQualityListFingerprint.result?.let { VideoQualityListFingerprint.resultOrThrow().let {
val constructorMethod = val constructorMethod =
it.mutableClass.methods.first { method -> MethodUtil.isConstructor(method) } it.mutableClass.methods.first { method -> MethodUtil.isConstructor(method) }
val overrideMethod = val overrideMethod =
@ -67,9 +67,9 @@ object OverrideQualityHookPatch : BytecodePatch(
"invoke-static {v$listRegister}, $INTEGRATIONS_VIDEO_QUALITY_CLASS_DESCRIPTOR->setVideoQualityList([Ljava/lang/Object;)V" "invoke-static {v$listRegister}, $INTEGRATIONS_VIDEO_QUALITY_CLASS_DESCRIPTOR->setVideoQualityList([Ljava/lang/Object;)V"
) )
} }
} ?: throw VideoQualityListFingerprint.exception }
VideoQualityPatchFingerprint.result?.let { VideoQualityPatchFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
it.mutableClass.staticFields.add( it.mutableClass.staticFields.add(
ImmutableField( ImmutableField(
@ -90,9 +90,9 @@ object OverrideQualityHookPatch : BytecodePatch(
""" """
) )
} }
} ?: throw VideoQualityPatchFingerprint.exception }
VideoQualityTextFingerprint.result?.let { VideoQualityTextFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val textIndex = it.scanResult.patternScanResult!!.endIndex val textIndex = it.scanResult.patternScanResult!!.endIndex
val textRegister = getInstruction<TwoRegisterInstruction>(textIndex).registerA val textRegister = getInstruction<TwoRegisterInstruction>(textIndex).registerA
@ -102,6 +102,6 @@ object OverrideQualityHookPatch : BytecodePatch(
"sput-object v$textRegister, $INTEGRATIONS_VIDEO_UTILS_CLASS_DESCRIPTOR->currentQuality:Ljava/lang/String;" "sput-object v$textRegister, $INTEGRATIONS_VIDEO_UTILS_CLASS_DESCRIPTOR->currentQuality:Ljava/lang/String;"
) )
} }
} ?: throw VideoQualityTextFingerprint.exception }
} }
} }

View File

@ -14,10 +14,10 @@ import app.revanced.patches.music.utils.overridespeed.fingerprints.PlaybackSpeed
import app.revanced.patches.music.utils.overridespeed.fingerprints.PlaybackSpeedOnClickListenerFingerprint import app.revanced.patches.music.utils.overridespeed.fingerprints.PlaybackSpeedOnClickListenerFingerprint
import app.revanced.patches.music.utils.overridespeed.fingerprints.PlaybackSpeedParentFingerprint import app.revanced.patches.music.utils.overridespeed.fingerprints.PlaybackSpeedParentFingerprint
import app.revanced.patches.music.utils.overridespeed.fingerprints.PlaybackSpeedPatchFingerprint import app.revanced.patches.music.utils.overridespeed.fingerprints.PlaybackSpeedPatchFingerprint
import app.revanced.util.exception
import app.revanced.util.getTargetIndex import app.revanced.util.getTargetIndex
import app.revanced.util.getWalkerMethod import app.revanced.util.getWalkerMethod
import app.revanced.util.getWideLiteralInstructionIndex import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -49,7 +49,7 @@ object OverrideSpeedHookPatch : BytecodePatch(
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
PlaybackSpeedOnClickListenerFingerprint.result?.let { PlaybackSpeedOnClickListenerFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val startIndex = getWideLiteralInstructionIndex(147448) val startIndex = getWideLiteralInstructionIndex(147448)
val iGetObjectIndex = getTargetIndex(startIndex, Opcode.IGET_OBJECT) val iGetObjectIndex = getTargetIndex(startIndex, Opcode.IGET_OBJECT)
@ -77,15 +77,15 @@ object OverrideSpeedHookPatch : BytecodePatch(
"sput-object v$iPutRegister, $INTEGRATIONS_PLAYBACK_SPEED_CLASS_DESCRIPTOR->objectClass:$objectClass" "sput-object v$iPutRegister, $INTEGRATIONS_PLAYBACK_SPEED_CLASS_DESCRIPTOR->objectClass:$objectClass"
) )
} }
} ?: throw PlaybackSpeedOnClickListenerFingerprint.exception }
PlaybackSpeedParentFingerprint.result?.let { parentResult -> PlaybackSpeedParentFingerprint.resultOrThrow().let { parentResult ->
PlaybackSpeedFingerprint.also { PlaybackSpeedFingerprint.also {
it.resolve( it.resolve(
context, context,
parentResult.classDef parentResult.classDef
) )
}.result?.let { }.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val startIndex = it.scanResult.patternScanResult!!.startIndex val startIndex = it.scanResult.patternScanResult!!.startIndex
val endIndex = it.scanResult.patternScanResult!!.endIndex val endIndex = it.scanResult.patternScanResult!!.endIndex
@ -108,10 +108,10 @@ object OverrideSpeedHookPatch : BytecodePatch(
) )
} }
} ?: throw PlaybackSpeedFingerprint.exception }
} ?: throw PlaybackSpeedParentFingerprint.exception }
PlaybackSpeedPatchFingerprint.result?.let { PlaybackSpeedPatchFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
it.mutableClass.staticFields.add( it.mutableClass.staticFields.add(
ImmutableField( ImmutableField(
@ -138,6 +138,6 @@ object OverrideSpeedHookPatch : BytecodePatch(
""" """
) )
} }
} ?: throw PlaybackSpeedPatchFingerprint.exception }
} }
} }

View File

@ -5,7 +5,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.music.utils.playerresponse.fingerprints.PlaybackStartDescriptorFingerprint import app.revanced.patches.music.utils.playerresponse.fingerprints.PlaybackStartDescriptorFingerprint
import app.revanced.util.exception import app.revanced.util.resultOrThrow
object PlayerResponsePatch : BytecodePatch( object PlayerResponsePatch : BytecodePatch(
setOf(PlaybackStartDescriptorFingerprint) setOf(PlaybackStartDescriptorFingerprint)
@ -37,8 +37,7 @@ object PlayerResponsePatch : BytecodePatch(
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
insertMethod = PlaybackStartDescriptorFingerprint.result?.mutableMethod insertMethod = PlaybackStartDescriptorFingerprint.resultOrThrow().mutableMethod
?: throw PlaybackStartDescriptorFingerprint.exception
} }

View File

@ -5,25 +5,24 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patches.music.utils.integrations.Constants.UTILS_PATH import app.revanced.patches.music.utils.integrations.Constants.UTILS_PATH
import app.revanced.patches.music.utils.playertype.fingerprint.PlayerTypeFingerprint import app.revanced.patches.music.utils.playertype.fingerprint.PlayerTypeFingerprint
import app.revanced.util.exception import app.revanced.util.resultOrThrow
@Suppress("unused") @Suppress("unused")
object PlayerTypeHookPatch : BytecodePatch( object PlayerTypeHookPatch : BytecodePatch(
setOf(PlayerTypeFingerprint) setOf(PlayerTypeFingerprint)
) { ) {
private const val INTEGRATIONS_CLASS_DESCRIPTOR =
"$UTILS_PATH/PlayerTypeHookPatch;"
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
PlayerTypeFingerprint.result?.let { PlayerTypeFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
addInstruction( addInstruction(
0, 0,
"invoke-static {p1}, $INTEGRATIONS_CLASS_DESCRIPTOR->setPlayerType(Ljava/lang/Enum;)V" "invoke-static {p1}, $INTEGRATIONS_CLASS_DESCRIPTOR->setPlayerType(Ljava/lang/Enum;)V"
) )
} }
} ?: throw PlayerTypeFingerprint.exception }
} }
private const val INTEGRATIONS_CLASS_DESCRIPTOR =
"$UTILS_PATH/PlayerTypeHookPatch;"
} }

View File

@ -13,8 +13,8 @@ import app.revanced.patches.music.utils.returnyoutubedislike.fingerprints.LikeFi
import app.revanced.patches.music.utils.returnyoutubedislike.fingerprints.RemoveLikeFingerprint import app.revanced.patches.music.utils.returnyoutubedislike.fingerprints.RemoveLikeFingerprint
import app.revanced.patches.music.utils.returnyoutubedislike.fingerprints.TextComponentFingerprint import app.revanced.patches.music.utils.returnyoutubedislike.fingerprints.TextComponentFingerprint
import app.revanced.patches.music.video.videoid.VideoIdPatch import app.revanced.patches.music.video.videoid.VideoIdPatch
import app.revanced.util.exception
import app.revanced.util.indexOfFirstInstruction import app.revanced.util.indexOfFirstInstruction
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
@ -42,18 +42,16 @@ object ReturnYouTubeDislikeBytecodePatch : BytecodePatch(
DislikeFingerprint.toPatch(Vote.DISLIKE), DislikeFingerprint.toPatch(Vote.DISLIKE),
RemoveLikeFingerprint.toPatch(Vote.REMOVE_LIKE) RemoveLikeFingerprint.toPatch(Vote.REMOVE_LIKE)
).forEach { (fingerprint, vote) -> ).forEach { (fingerprint, vote) ->
with(fingerprint.result ?: throw fingerprint.exception) { fingerprint.resultOrThrow().mutableMethod.addInstructions(
mutableMethod.addInstructions( 0,
0, """
"""
const/4 v0, ${vote.value} const/4 v0, ${vote.value}
invoke-static {v0}, $INTEGRATIONS_RYD_CLASS_DESCRIPTOR->sendVote(I)V invoke-static {v0}, $INTEGRATIONS_RYD_CLASS_DESCRIPTOR->sendVote(I)V
""" """
) )
}
} }
TextComponentFingerprint.result?.let { TextComponentFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val insertIndex = indexOfFirstInstruction { val insertIndex = indexOfFirstInstruction {
opcode == Opcode.INVOKE_STATIC opcode == Opcode.INVOKE_STATIC
@ -68,7 +66,7 @@ object ReturnYouTubeDislikeBytecodePatch : BytecodePatch(
""" """
) )
} }
} ?: throw TextComponentFingerprint.exception }
VideoIdPatch.hookVideoId("$INTEGRATIONS_RYD_CLASS_DESCRIPTOR->newVideoLoaded(Ljava/lang/String;)V") VideoIdPatch.hookVideoId("$INTEGRATIONS_RYD_CLASS_DESCRIPTOR->newVideoLoaded(Ljava/lang/String;)V")

View File

@ -16,8 +16,8 @@ import app.revanced.patches.music.utils.settings.fingerprints.GoogleApiActivityF
import app.revanced.patches.music.utils.settings.fingerprints.PreferenceFingerprint import app.revanced.patches.music.utils.settings.fingerprints.PreferenceFingerprint
import app.revanced.patches.music.utils.settings.fingerprints.SettingsHeadersFragmentFingerprint import app.revanced.patches.music.utils.settings.fingerprints.SettingsHeadersFragmentFingerprint
import app.revanced.patches.shared.settings.fingerprints.SharedSettingFingerprint import app.revanced.patches.shared.settings.fingerprints.SharedSettingFingerprint
import app.revanced.util.exception
import app.revanced.util.getTargetIndex import app.revanced.util.getTargetIndex
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -47,7 +47,7 @@ object SettingsBytecodePatch : BytecodePatch(
/** /**
* Set SharedPrefCategory * Set SharedPrefCategory
*/ */
SharedSettingFingerprint.result?.let { SharedSettingFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val stringIndex = getTargetIndex(Opcode.CONST_STRING) val stringIndex = getTargetIndex(Opcode.CONST_STRING)
val stringRegister = getInstruction<OneRegisterInstruction>(stringIndex).registerA val stringRegister = getInstruction<OneRegisterInstruction>(stringIndex).registerA
@ -57,12 +57,12 @@ object SettingsBytecodePatch : BytecodePatch(
"const-string v$stringRegister, \"youtube\"" "const-string v$stringRegister, \"youtube\""
) )
} }
} ?: throw SharedSettingFingerprint.exception }
/** /**
* Inject settings Activity * Inject settings Activity
*/ */
SettingsHeadersFragmentFingerprint.result?.let { SettingsHeadersFragmentFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.endIndex val targetIndex = it.scanResult.patternScanResult!!.endIndex
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
@ -72,12 +72,12 @@ object SettingsBytecodePatch : BytecodePatch(
"invoke-static {v$targetRegister}, $INTEGRATIONS_ACTIVITY_CLASS_DESCRIPTOR->setActivity(Ljava/lang/Object;)V" "invoke-static {v$targetRegister}, $INTEGRATIONS_ACTIVITY_CLASS_DESCRIPTOR->setActivity(Ljava/lang/Object;)V"
) )
} }
} ?: throw SettingsHeadersFragmentFingerprint.exception }
/** /**
* Values are loaded when preferences change * Values are loaded when preferences change
*/ */
PreferenceFingerprint.result?.let { PreferenceFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.endIndex val targetIndex = it.scanResult.patternScanResult!!.endIndex
val keyRegister = getInstruction<FiveRegisterInstruction>(targetIndex).registerD val keyRegister = getInstruction<FiveRegisterInstruction>(targetIndex).registerD
@ -88,12 +88,12 @@ object SettingsBytecodePatch : BytecodePatch(
"invoke-static {v$keyRegister, v$valueRegister}, $INTEGRATIONS_FRAGMENT_CLASS_DESCRIPTOR->onPreferenceChanged(Ljava/lang/String;Z)V" "invoke-static {v$keyRegister, v$valueRegister}, $INTEGRATIONS_FRAGMENT_CLASS_DESCRIPTOR->onPreferenceChanged(Ljava/lang/String;Z)V"
) )
} }
} ?: throw PreferenceFingerprint.exception }
/** /**
* Inject dummy Activity for intent * Inject dummy Activity for intent
*/ */
GoogleApiActivityFingerprint.result?.let { GoogleApiActivityFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
addInstructionsWithLabels( addInstructionsWithLabels(
1, """ 1, """
@ -104,7 +104,7 @@ object SettingsBytecodePatch : BytecodePatch(
""", ExternalLabel("show", getInstruction(1)) """, ExternalLabel("show", getInstruction(1))
) )
} }
} ?: throw GoogleApiActivityFingerprint.exception }
injectInit("InitializationPatch", "setDeviceInformation") injectInit("InitializationPatch", "setDeviceInformation")
injectInit("InitializationPatch", "onCreate") injectInit("InitializationPatch", "onCreate")

View File

@ -14,9 +14,9 @@ import app.revanced.patches.music.utils.sponsorblock.fingerprints.MusicPlaybackC
import app.revanced.patches.music.utils.sponsorblock.fingerprints.SeekbarOnDrawFingerprint import app.revanced.patches.music.utils.sponsorblock.fingerprints.SeekbarOnDrawFingerprint
import app.revanced.patches.music.video.information.VideoInformationPatch import app.revanced.patches.music.video.information.VideoInformationPatch
import app.revanced.patches.music.video.videoid.VideoIdPatch import app.revanced.patches.music.video.videoid.VideoIdPatch
import app.revanced.util.exception
import app.revanced.util.getTargetIndexWithMethodReferenceName import app.revanced.util.getTargetIndexWithMethodReferenceName
import app.revanced.util.getTargetIndexWithMethodReferenceNameReversed import app.revanced.util.getTargetIndexWithMethodReferenceNameReversed
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
@ -55,11 +55,10 @@ object SponsorBlockBytecodePatch : BytecodePatch(
/** /**
* Responsible for seekbar in fullscreen * Responsible for seekbar in fullscreen
*/ */
val seekBarClass = SeekBarConstructorFingerprint.result?.mutableClass val seekBarClass = SeekBarConstructorFingerprint.resultOrThrow().mutableClass
?: throw SeekBarConstructorFingerprint.exception
SeekbarOnDrawFingerprint.resolve(context, seekBarClass) SeekbarOnDrawFingerprint.resolve(context, seekBarClass)
SeekbarOnDrawFingerprint.result?.let { SeekbarOnDrawFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
// Initialize seekbar method // Initialize seekbar method
addInstructions( addInstructions(
@ -88,22 +87,22 @@ object SponsorBlockBytecodePatch : BytecodePatch(
"$INTEGRATIONS_SEGMENT_PLAYBACK_CONTROLLER_CLASS_DESCRIPTOR->drawSponsorTimeBars(Landroid/graphics/Canvas;F)V" "$INTEGRATIONS_SEGMENT_PLAYBACK_CONTROLLER_CLASS_DESCRIPTOR->drawSponsorTimeBars(Landroid/graphics/Canvas;F)V"
) )
} }
} ?: throw SeekbarOnDrawFingerprint.exception }
/** /**
* Responsible for seekbar in player * Responsible for seekbar in player
*/ */
MusicPlaybackControlsTimeBarOnMeasureFingerprint.result?.let { MusicPlaybackControlsTimeBarOnMeasureFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val rectangleIndex = it.scanResult.patternScanResult!!.startIndex val rectangleIndex = it.scanResult.patternScanResult!!.startIndex
val rectangleReference = val rectangleReference =
getInstruction<ReferenceInstruction>(rectangleIndex).reference getInstruction<ReferenceInstruction>(rectangleIndex).reference
rectangleFieldName = (rectangleReference as FieldReference).name rectangleFieldName = (rectangleReference as FieldReference).name
} }
} ?: throw MusicPlaybackControlsTimeBarOnMeasureFingerprint.exception }
MusicPlaybackControlsTimeBarDrawFingerprint.result?.let { MusicPlaybackControlsTimeBarDrawFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
// Initialize seekbar method // Initialize seekbar method
addInstructions( addInstructions(
@ -123,7 +122,7 @@ object SponsorBlockBytecodePatch : BytecodePatch(
"$INTEGRATIONS_SEGMENT_PLAYBACK_CONTROLLER_CLASS_DESCRIPTOR->drawSponsorTimeBars(Landroid/graphics/Canvas;F)V" "$INTEGRATIONS_SEGMENT_PLAYBACK_CONTROLLER_CLASS_DESCRIPTOR->drawSponsorTimeBars(Landroid/graphics/Canvas;F)V"
) )
} }
} ?: throw MusicPlaybackControlsTimeBarDrawFingerprint.exception }
/** /**
* Set current video id * Set current video id

View File

@ -7,7 +7,7 @@ import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patches.music.utils.integrations.Constants.UTILS_PATH import app.revanced.patches.music.utils.integrations.Constants.UTILS_PATH
import app.revanced.patches.music.utils.videotype.fingerprint.VideoTypeFingerprint import app.revanced.patches.music.utils.videotype.fingerprint.VideoTypeFingerprint
import app.revanced.patches.music.utils.videotype.fingerprint.VideoTypeParentFingerprint import app.revanced.patches.music.utils.videotype.fingerprint.VideoTypeParentFingerprint
import app.revanced.util.exception import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
@Suppress("SpellCheckingInspection", "unused") @Suppress("SpellCheckingInspection", "unused")
@ -19,13 +19,13 @@ object VideoTypeHookPatch : BytecodePatch(
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
VideoTypeParentFingerprint.result?.let { parentResult -> VideoTypeParentFingerprint.resultOrThrow().let { parentResult ->
VideoTypeFingerprint.also { VideoTypeFingerprint.also {
it.resolve( it.resolve(
context, context,
parentResult.classDef parentResult.classDef
) )
}.result?.let { }.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.startIndex + 3 val insertIndex = it.scanResult.patternScanResult!!.startIndex + 3
val referenceIndex = insertIndex + 1 val referenceIndex = insertIndex + 1
@ -41,7 +41,7 @@ object VideoTypeHookPatch : BytecodePatch(
""" """
) )
} }
} ?: throw VideoTypeFingerprint.exception }
} ?: throw VideoTypeParentFingerprint.exception }
} }
} }

View File

@ -16,10 +16,10 @@ import app.revanced.patches.music.video.information.fingerprints.PlayerControlle
import app.revanced.patches.music.video.information.fingerprints.VideoEndFingerprint import app.revanced.patches.music.video.information.fingerprints.VideoEndFingerprint
import app.revanced.patches.music.video.information.fingerprints.VideoLengthFingerprint import app.revanced.patches.music.video.information.fingerprints.VideoLengthFingerprint
import app.revanced.patches.music.video.videoid.VideoIdPatch import app.revanced.patches.music.video.videoid.VideoIdPatch
import app.revanced.util.exception
import app.revanced.util.getTargetIndexWithFieldReferenceTypeReversed import app.revanced.util.getTargetIndexWithFieldReferenceTypeReversed
import app.revanced.util.getTargetIndexWithMethodReferenceNameReversed import app.revanced.util.getTargetIndexWithMethodReferenceNameReversed
import app.revanced.util.getWalkerMethod import app.revanced.util.getWalkerMethod
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.builder.MutableMethodImplementation import com.android.tools.smali.dexlib2.builder.MutableMethodImplementation
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -90,7 +90,7 @@ object VideoInformationPatch : BytecodePatch(
) )
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
VideoEndFingerprint.result?.let { VideoEndFingerprint.resultOrThrow().let {
playerInitMethod = playerInitMethod =
it.mutableClass.methods.first { method -> MethodUtil.isConstructor(method) } it.mutableClass.methods.first { method -> MethodUtil.isConstructor(method) }
@ -120,19 +120,19 @@ object VideoInformationPatch : BytecodePatch(
) )
it.mutableClass.methods.add(seekHelperMethod) it.mutableClass.methods.add(seekHelperMethod)
} }
} ?: throw VideoEndFingerprint.exception }
/** /**
* Set current video length * Set current video length
*/ */
SeekBarConstructorFingerprint.result?.classDef?.let { classDef -> SeekBarConstructorFingerprint.resultOrThrow().classDef.let { classDef ->
VideoLengthFingerprint.also { VideoLengthFingerprint.also {
it.resolve( it.resolve(
context, context,
classDef classDef
) )
}.result?.let { }.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val invalidateIndex = getTargetIndexWithMethodReferenceNameReversed("invalidate") val invalidateIndex = getTargetIndexWithMethodReferenceNameReversed("invalidate")
val rectangleIndex = getTargetIndexWithFieldReferenceTypeReversed(invalidateIndex + 1, "Landroid/graphics/Rect;") val rectangleIndex = getTargetIndexWithFieldReferenceTypeReversed(invalidateIndex + 1, "Landroid/graphics/Rect;")
@ -149,16 +149,16 @@ object VideoInformationPatch : BytecodePatch(
"invoke-static {v$videoLengthRegister, v$dummyRegisterForLong}, $INTEGRATIONS_CLASS_DESCRIPTOR->setVideoLength(J)V" "invoke-static {v$videoLengthRegister, v$dummyRegisterForLong}, $INTEGRATIONS_CLASS_DESCRIPTOR->setVideoLength(J)V"
) )
} }
} ?: throw VideoLengthFingerprint.exception }
} ?: throw SeekBarConstructorFingerprint.exception }
/** /**
* Set the video time method * Set the video time method
*/ */
PlayerControllerSetTimeReferenceFingerprint.result?.let { PlayerControllerSetTimeReferenceFingerprint.resultOrThrow().let {
timeMethod = it.getWalkerMethod(context, it.scanResult.patternScanResult!!.startIndex) timeMethod = it.getWalkerMethod(context, it.scanResult.patternScanResult!!.startIndex)
} ?: throw PlayerControllerSetTimeReferenceFingerprint.exception }
/** /**

View File

@ -11,8 +11,8 @@ import app.revanced.patches.music.utils.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.patches.music.video.quality.fingerprints.UserQualityChangeFingerprint import app.revanced.patches.music.video.quality.fingerprints.UserQualityChangeFingerprint
import app.revanced.patches.music.video.videoid.VideoIdPatch import app.revanced.patches.music.video.videoid.VideoIdPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction21c import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction21c
@Suppress("unused") @Suppress("unused")
@ -32,7 +32,7 @@ object VideoQualityPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
UserQualityChangeFingerprint.result?.let { UserQualityChangeFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val endIndex = it.scanResult.patternScanResult!!.endIndex val endIndex = it.scanResult.patternScanResult!!.endIndex
val qualityChangedClass = val qualityChangedClass =
@ -54,7 +54,7 @@ object VideoQualityPatch : BaseBytecodePatch(
) )
} ?: throw PatchException("Failed to find onItemClick method") } ?: throw PatchException("Failed to find onItemClick method")
} }
} ?: throw UserQualityChangeFingerprint.exception }
VideoIdPatch.hookVideoId("$INTEGRATIONS_VIDEO_QUALITY_CLASS_DESCRIPTOR->newVideoStarted(Ljava/lang/String;)V") VideoIdPatch.hookVideoId("$INTEGRATIONS_VIDEO_QUALITY_CLASS_DESCRIPTOR->newVideoStarted(Ljava/lang/String;)V")

View File

@ -10,8 +10,8 @@ import app.revanced.patches.music.utils.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.patches.music.video.speed.fingerprints.PlaybackSpeedBottomSheetFingerprint import app.revanced.patches.music.video.speed.fingerprints.PlaybackSpeedBottomSheetFingerprint
import app.revanced.patches.music.video.speed.fingerprints.PlaybackSpeedBottomSheetParentFingerprint import app.revanced.patches.music.video.speed.fingerprints.PlaybackSpeedBottomSheetParentFingerprint
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
@Suppress("unused") @Suppress("unused")
@ -30,13 +30,13 @@ object PlaybackSpeedPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
PlaybackSpeedBottomSheetParentFingerprint.result?.let { parentResult -> PlaybackSpeedBottomSheetParentFingerprint.resultOrThrow().let { parentResult ->
PlaybackSpeedBottomSheetFingerprint.also { PlaybackSpeedBottomSheetFingerprint.also {
it.resolve( it.resolve(
context, context,
parentResult.classDef parentResult.classDef
) )
}.result?.let { }.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.startIndex val targetIndex = it.scanResult.patternScanResult!!.startIndex
val targetRegister = val targetRegister =
@ -47,8 +47,8 @@ object PlaybackSpeedPatch : BaseBytecodePatch(
"invoke-static {v$targetRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->userChangedSpeed(F)V" "invoke-static {v$targetRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->userChangedSpeed(F)V"
) )
} }
} ?: throw PlaybackSpeedBottomSheetFingerprint.exception }
} ?: throw PlaybackSpeedBottomSheetParentFingerprint.exception }
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.VIDEO, CategoryType.VIDEO,

View File

@ -10,8 +10,8 @@ import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.music.video.videoid.fingerprints.PlayerResponseModelStoryboardRendererFingerprint import app.revanced.patches.music.video.videoid.fingerprints.PlayerResponseModelStoryboardRendererFingerprint
import app.revanced.patches.music.video.videoid.fingerprints.VideoIdParentFingerprint import app.revanced.patches.music.video.videoid.fingerprints.VideoIdParentFingerprint
import app.revanced.util.exception
import app.revanced.util.getTargetIndexReversed import app.revanced.util.getTargetIndexReversed
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
@ -36,7 +36,7 @@ object VideoIdPatch : BytecodePatch(
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
VideoIdParentFingerprint.result?.let { result -> VideoIdParentFingerprint.resultOrThrow().let { result ->
val targetIndex = result.scanResult.patternScanResult!!.endIndex val targetIndex = result.scanResult.patternScanResult!!.endIndex
val targetReference = result.mutableMethod.getInstruction<ReferenceInstruction>(targetIndex).reference val targetReference = result.mutableMethod.getInstruction<ReferenceInstruction>(targetIndex).reference
val targetClass = (targetReference as FieldReference).type val targetClass = (targetReference as FieldReference).type
@ -55,14 +55,17 @@ object VideoIdPatch : BytecodePatch(
videoIdRegister = getInstruction<OneRegisterInstruction>(videoIdInsertIndex - 1).registerA videoIdRegister = getInstruction<OneRegisterInstruction>(videoIdInsertIndex - 1).registerA
} }
} ?: throw VideoIdParentFingerprint.exception }
PlayerResponseModelStoryboardRendererFingerprint.result PlayerResponseModelStoryboardRendererFingerprint
?.mutableClass?.methods?.find { method -> method.name == backgroundPlaybackMethodName } .resultOrThrow()
.mutableClass
.methods
.find { method -> method.name == backgroundPlaybackMethodName }
?.apply { ?.apply {
backgroundPlaybackMethod = this backgroundPlaybackMethod = this
backgroundPlaybackInsertIndex = implementation!!.instructions.size - 1 backgroundPlaybackInsertIndex = implementation!!.instructions.size - 1
} ?: throw PlayerResponseModelStoryboardRendererFingerprint.exception }
} }
override fun close () { override fun close () {

View File

@ -7,8 +7,8 @@ import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.reddit.ad.comments.fingerprints.CommentAdsFingerprint import app.revanced.patches.reddit.ad.comments.fingerprints.CommentAdsFingerprint
import app.revanced.patches.reddit.utils.integrations.Constants.PATCHES_PATH import app.revanced.patches.reddit.utils.integrations.Constants.PATCHES_PATH
import app.revanced.util.exception
import app.revanced.util.getWalkerMethod import app.revanced.util.getWalkerMethod
import app.revanced.util.resultOrThrow
object CommentAdsPatch : BytecodePatch( object CommentAdsPatch : BytecodePatch(
setOf(CommentAdsFingerprint) setOf(CommentAdsFingerprint)
@ -17,7 +17,7 @@ object CommentAdsPatch : BytecodePatch(
"$PATCHES_PATH/GeneralAdsPatch;->hideCommentAds()Z" "$PATCHES_PATH/GeneralAdsPatch;->hideCommentAds()Z"
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
CommentAdsFingerprint.result?.apply { CommentAdsFingerprint.resultOrThrow().apply {
val walkerMethod = getWalkerMethod(context, scanResult.patternScanResult!!.startIndex) val walkerMethod = getWalkerMethod(context, scanResult.patternScanResult!!.startIndex)
walkerMethod.apply { walkerMethod.apply {
addInstructionsWithLabels( addInstructionsWithLabels(
@ -31,7 +31,7 @@ object CommentAdsPatch : BytecodePatch(
""", ExternalLabel("show", getInstruction(0)) """, ExternalLabel("show", getInstruction(0))
) )
} }
} ?: throw CommentAdsFingerprint.exception }
} }
} }

View File

@ -13,10 +13,10 @@ import app.revanced.patches.reddit.utils.integrations.Constants.COMPATIBLE_PACKA
import app.revanced.patches.reddit.utils.integrations.Constants.PATCHES_PATH import app.revanced.patches.reddit.utils.integrations.Constants.PATCHES_PATH
import app.revanced.patches.reddit.utils.settings.SettingsBytecodePatch.updateSettingsStatus import app.revanced.patches.reddit.utils.settings.SettingsBytecodePatch.updateSettingsStatus
import app.revanced.patches.reddit.utils.settings.SettingsPatch import app.revanced.patches.reddit.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getTargetIndexWithFieldReferenceName import app.revanced.util.getTargetIndexWithFieldReferenceName
import app.revanced.util.getTargetIndexWithMethodReferenceName import app.revanced.util.getTargetIndexWithMethodReferenceName
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
@ -41,7 +41,7 @@ object AdsPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
// region Filter promoted ads (does not work in popular or latest feed) // region Filter promoted ads (does not work in popular or latest feed)
AdPostFingerprint.result?.let { AdPostFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val targetIndex = getTargetIndexWithFieldReferenceName("children") val targetIndex = getTargetIndexWithFieldReferenceName("children")
val targetRegister = getInstruction<TwoRegisterInstruction>(targetIndex).registerA val targetRegister = getInstruction<TwoRegisterInstruction>(targetIndex).registerA
@ -53,12 +53,12 @@ object AdsPatch : BaseBytecodePatch(
""" """
) )
} }
} ?: throw AdPostFingerprint.exception }
// The new feeds work by inserting posts into lists. // The new feeds work by inserting posts into lists.
// AdElementConverter is conveniently responsible for inserting all feed ads. // AdElementConverter is conveniently responsible for inserting all feed ads.
// By removing the appending instruction no ad posts gets appended to the feed. // By removing the appending instruction no ad posts gets appended to the feed.
NewAdPostFingerprint.result?.let { NewAdPostFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val targetIndex = getTargetIndexWithMethodReferenceName("add") val targetIndex = getTargetIndexWithMethodReferenceName("add")
val targetRegister = val targetRegister =
@ -72,7 +72,7 @@ object AdsPatch : BaseBytecodePatch(
""", ExternalLabel("show", getInstruction(targetIndex + 1)) """, ExternalLabel("show", getInstruction(targetIndex + 1))
) )
} }
} ?: throw NewAdPostFingerprint.exception }
updateSettingsStatus("enableGeneralAds") updateSettingsStatus("enableGeneralAds")

View File

@ -8,8 +8,8 @@ import app.revanced.patches.reddit.utils.integrations.Constants.COMPATIBLE_PACKA
import app.revanced.patches.reddit.utils.integrations.Constants.PATCHES_PATH import app.revanced.patches.reddit.utils.integrations.Constants.PATCHES_PATH
import app.revanced.patches.reddit.utils.settings.SettingsBytecodePatch.updateSettingsStatus import app.revanced.patches.reddit.utils.settings.SettingsBytecodePatch.updateSettingsStatus
import app.revanced.patches.reddit.utils.settings.SettingsPatch import app.revanced.patches.reddit.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
@Suppress("unused") @Suppress("unused")
@ -25,7 +25,7 @@ object NavigationButtonsPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
BottomNavScreenFingerprint.result?.let { BottomNavScreenFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val startIndex = it.scanResult.patternScanResult!!.startIndex val startIndex = it.scanResult.patternScanResult!!.startIndex
val targetRegister = val targetRegister =
@ -36,7 +36,7 @@ object NavigationButtonsPatch : BaseBytecodePatch(
"invoke-static {v$targetRegister}, $INTEGRATIONS_METHOD_DESCRIPTOR" "invoke-static {v$targetRegister}, $INTEGRATIONS_METHOD_DESCRIPTOR"
) )
} }
} ?: throw BottomNavScreenFingerprint.exception }
updateSettingsStatus("enableNavigationButtons") updateSettingsStatus("enableNavigationButtons")

View File

@ -4,8 +4,8 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patches.reddit.layout.premiumicon.fingerprints.PremiumIconFingerprint import app.revanced.patches.reddit.layout.premiumicon.fingerprints.PremiumIconFingerprint
import app.revanced.patches.reddit.utils.integrations.Constants.COMPATIBLE_PACKAGE import app.revanced.patches.reddit.utils.integrations.Constants.COMPATIBLE_PACKAGE
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
@Suppress("unused") @Suppress("unused")
object PremiumIconPatch : BaseBytecodePatch( object PremiumIconPatch : BaseBytecodePatch(
@ -16,7 +16,7 @@ object PremiumIconPatch : BaseBytecodePatch(
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
PremiumIconFingerprint.result?.let { PremiumIconFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
addInstructions( addInstructions(
0, """ 0, """
@ -25,7 +25,7 @@ object PremiumIconPatch : BaseBytecodePatch(
""" """
) )
} }
} ?: throw PremiumIconFingerprint.exception }
} }
} }

View File

@ -9,12 +9,12 @@ import app.revanced.patches.reddit.utils.integrations.Constants.COMPATIBLE_PACKA
import app.revanced.patches.reddit.utils.integrations.Constants.PATCHES_PATH import app.revanced.patches.reddit.utils.integrations.Constants.PATCHES_PATH
import app.revanced.patches.reddit.utils.settings.SettingsBytecodePatch.updateSettingsStatus import app.revanced.patches.reddit.utils.settings.SettingsBytecodePatch.updateSettingsStatus
import app.revanced.patches.reddit.utils.settings.SettingsPatch import app.revanced.patches.reddit.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getTargetIndex import app.revanced.util.getTargetIndex
import app.revanced.util.getTargetIndexReversed import app.revanced.util.getTargetIndexReversed
import app.revanced.util.getTargetIndexWithFieldReferenceName import app.revanced.util.getTargetIndexWithFieldReferenceName
import app.revanced.util.getTargetIndexWithReference import app.revanced.util.getTargetIndexWithReference
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
@ -35,7 +35,7 @@ object RecentlyVisitedShelfPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
CommunityDrawerPresenterFingerprint.result?.let { CommunityDrawerPresenterFingerprint.resultOrThrow().let {
lateinit var recentlyVisitedReference: Reference lateinit var recentlyVisitedReference: Reference
it.mutableClass.methods.find { method -> method.name == "<init>" } it.mutableClass.methods.find { method -> method.name == "<init>" }
@ -63,7 +63,7 @@ object RecentlyVisitedShelfPatch : BaseBytecodePatch(
) )
} }
} }
} ?: throw CommunityDrawerPresenterFingerprint.exception }
updateSettingsStatus("enableRecentlyVisitedShelf") updateSettingsStatus("enableRecentlyVisitedShelf")

View File

@ -10,8 +10,8 @@ import app.revanced.patches.reddit.utils.integrations.Constants.PATCHES_PATH
import app.revanced.patches.reddit.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.reddit.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.reddit.utils.settings.SettingsBytecodePatch.updateSettingsStatus import app.revanced.patches.reddit.utils.settings.SettingsBytecodePatch.updateSettingsStatus
import app.revanced.patches.reddit.utils.settings.SettingsPatch import app.revanced.patches.reddit.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
@Suppress("unused") @Suppress("unused")
object ScreenshotPopupPatch : BaseBytecodePatch( object ScreenshotPopupPatch : BaseBytecodePatch(
@ -29,7 +29,7 @@ object ScreenshotPopupPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
ScreenshotTakenBannerFingerprint.result?.let { ScreenshotTakenBannerFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
addInstructionsWithLabels( addInstructionsWithLabels(
0, """ 0, """
@ -40,7 +40,7 @@ object ScreenshotPopupPatch : BaseBytecodePatch(
""", ExternalLabel("dismiss", getInstruction(0)) """, ExternalLabel("dismiss", getInstruction(0))
) )
} }
} ?: throw ScreenshotTakenBannerFingerprint.exception }
updateSettingsStatus("enableScreenshotPopup") updateSettingsStatus("enableScreenshotPopup")

View File

@ -12,9 +12,9 @@ import app.revanced.patches.reddit.utils.resourceid.SharedResourceIdPatch.Cancel
import app.revanced.patches.reddit.utils.resourceid.SharedResourceIdPatch.TextAppearanceRedditBaseOldButtonColored import app.revanced.patches.reddit.utils.resourceid.SharedResourceIdPatch.TextAppearanceRedditBaseOldButtonColored
import app.revanced.patches.reddit.utils.settings.SettingsBytecodePatch.updateSettingsStatus import app.revanced.patches.reddit.utils.settings.SettingsBytecodePatch.updateSettingsStatus
import app.revanced.patches.reddit.utils.settings.SettingsPatch import app.revanced.patches.reddit.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getWideLiteralInstructionIndex import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -37,7 +37,7 @@ object SubRedditDialogPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
FrequentUpdatesSheetScreenFingerprint.result?.let { FrequentUpdatesSheetScreenFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val cancelButtonViewIndex = getWideLiteralInstructionIndex(CancelButton) + 2 val cancelButtonViewIndex = getWideLiteralInstructionIndex(CancelButton) + 2
val cancelButtonViewRegister = getInstruction<OneRegisterInstruction>(cancelButtonViewIndex).registerA val cancelButtonViewRegister = getInstruction<OneRegisterInstruction>(cancelButtonViewIndex).registerA
@ -47,9 +47,9 @@ object SubRedditDialogPatch : BaseBytecodePatch(
"invoke-static {v$cancelButtonViewRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->dismissDialog(Landroid/view/View;)V" "invoke-static {v$cancelButtonViewRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->dismissDialog(Landroid/view/View;)V"
) )
} }
} ?: throw FrequentUpdatesSheetScreenFingerprint.exception }
RedditAlertDialogsFingerprint.result?.let { RedditAlertDialogsFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val insertIndex = getWideLiteralInstructionIndex(TextAppearanceRedditBaseOldButtonColored) + 1 val insertIndex = getWideLiteralInstructionIndex(TextAppearanceRedditBaseOldButtonColored) + 1
val insertRegister = getInstruction<FiveRegisterInstruction>(insertIndex).registerC val insertRegister = getInstruction<FiveRegisterInstruction>(insertIndex).registerC
@ -59,7 +59,7 @@ object SubRedditDialogPatch : BaseBytecodePatch(
"invoke-static {v$insertRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->confirmDialog(Landroid/widget/TextView;)V" "invoke-static {v$insertRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->confirmDialog(Landroid/widget/TextView;)V"
) )
} }
} ?: throw RedditAlertDialogsFingerprint.exception }
updateSettingsStatus("enableSubRedditDialog") updateSettingsStatus("enableSubRedditDialog")

View File

@ -10,9 +10,9 @@ import app.revanced.patches.reddit.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.reddit.utils.resourceid.SharedResourceIdPatch.ToolBarNavSearchCtaContainer import app.revanced.patches.reddit.utils.resourceid.SharedResourceIdPatch.ToolBarNavSearchCtaContainer
import app.revanced.patches.reddit.utils.settings.SettingsBytecodePatch.updateSettingsStatus import app.revanced.patches.reddit.utils.settings.SettingsBytecodePatch.updateSettingsStatus
import app.revanced.patches.reddit.utils.settings.SettingsPatch import app.revanced.patches.reddit.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getWideLiteralInstructionIndex import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Suppress("unused") @Suppress("unused")
@ -31,7 +31,7 @@ object ToolBarButtonPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
HomePagerScreenFingerprint.result?.let { HomePagerScreenFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val targetIndex = val targetIndex =
getWideLiteralInstructionIndex(ToolBarNavSearchCtaContainer) + 3 getWideLiteralInstructionIndex(ToolBarNavSearchCtaContainer) + 3
@ -43,7 +43,7 @@ object ToolBarButtonPatch : BaseBytecodePatch(
"invoke-static {v$targetRegister}, $INTEGRATIONS_METHOD_DESCRIPTOR" "invoke-static {v$targetRegister}, $INTEGRATIONS_METHOD_DESCRIPTOR"
) )
} }
} ?: throw HomePagerScreenFingerprint.exception }
updateSettingsStatus("enableToolBarButton") updateSettingsStatus("enableToolBarButton")

View File

@ -7,8 +7,8 @@ import app.revanced.patches.reddit.utils.integrations.Constants.COMPATIBLE_PACKA
import app.revanced.patches.reddit.utils.integrations.Constants.PATCHES_PATH import app.revanced.patches.reddit.utils.integrations.Constants.PATCHES_PATH
import app.revanced.patches.reddit.utils.settings.SettingsBytecodePatch.updateSettingsStatus import app.revanced.patches.reddit.utils.settings.SettingsBytecodePatch.updateSettingsStatus
import app.revanced.patches.reddit.utils.settings.SettingsPatch import app.revanced.patches.reddit.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
@Suppress("unused") @Suppress("unused")
object OpenLinksDirectlyPatch : BaseBytecodePatch( object OpenLinksDirectlyPatch : BaseBytecodePatch(
@ -24,7 +24,7 @@ object OpenLinksDirectlyPatch : BaseBytecodePatch(
"parseRedirectUri(Landroid/net/Uri;)Landroid/net/Uri;" "parseRedirectUri(Landroid/net/Uri;)Landroid/net/Uri;"
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
ScreenNavigatorFingerprint.result?.let { ScreenNavigatorFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
addInstructions( addInstructions(
0, """ 0, """
@ -33,7 +33,7 @@ object OpenLinksDirectlyPatch : BaseBytecodePatch(
""" """
) )
} }
} ?: throw ScreenNavigatorFingerprint.exception }
updateSettingsStatus("enableOpenLinksDirectly") updateSettingsStatus("enableOpenLinksDirectly")

View File

@ -9,9 +9,9 @@ import app.revanced.patches.reddit.utils.integrations.Constants.COMPATIBLE_PACKA
import app.revanced.patches.reddit.utils.integrations.Constants.PATCHES_PATH import app.revanced.patches.reddit.utils.integrations.Constants.PATCHES_PATH
import app.revanced.patches.reddit.utils.settings.SettingsBytecodePatch.updateSettingsStatus import app.revanced.patches.reddit.utils.settings.SettingsBytecodePatch.updateSettingsStatus
import app.revanced.patches.reddit.utils.settings.SettingsPatch import app.revanced.patches.reddit.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getStringInstructionIndex import app.revanced.util.getStringInstructionIndex
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
@Suppress("unused") @Suppress("unused")
object OpenLinksExternallyPatch : BaseBytecodePatch( object OpenLinksExternallyPatch : BaseBytecodePatch(
@ -25,7 +25,7 @@ object OpenLinksExternallyPatch : BaseBytecodePatch(
"$PATCHES_PATH/OpenLinksExternallyPatch;" "$PATCHES_PATH/OpenLinksExternallyPatch;"
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
ScreenNavigatorFingerprint.result?.let { ScreenNavigatorFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val insertIndex = getStringInstructionIndex("uri") + 2 val insertIndex = getStringInstructionIndex("uri") + 2
@ -38,7 +38,7 @@ object OpenLinksExternallyPatch : BaseBytecodePatch(
""", ExternalLabel("dismiss", getInstruction(insertIndex)) """, ExternalLabel("dismiss", getInstruction(insertIndex))
) )
} }
} ?: throw ScreenNavigatorFingerprint.exception }
updateSettingsStatus("enableOpenLinksExternally") updateSettingsStatus("enableOpenLinksExternally")

View File

@ -9,8 +9,8 @@ import app.revanced.patches.reddit.utils.integrations.Constants.COMPATIBLE_PACKA
import app.revanced.patches.reddit.utils.integrations.Constants.PATCHES_PATH import app.revanced.patches.reddit.utils.integrations.Constants.PATCHES_PATH
import app.revanced.patches.reddit.utils.settings.SettingsBytecodePatch.updateSettingsStatus import app.revanced.patches.reddit.utils.settings.SettingsBytecodePatch.updateSettingsStatus
import app.revanced.patches.reddit.utils.settings.SettingsPatch import app.revanced.patches.reddit.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
@Suppress("unused") @Suppress("unused")
object SanitizeUrlQueryPatch : BaseBytecodePatch( object SanitizeUrlQueryPatch : BaseBytecodePatch(
@ -24,7 +24,7 @@ object SanitizeUrlQueryPatch : BaseBytecodePatch(
"$PATCHES_PATH/SanitizeUrlQueryPatch;->stripQueryParameters()Z" "$PATCHES_PATH/SanitizeUrlQueryPatch;->stripQueryParameters()Z"
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
ShareLinkFormatterFingerprint.result?.let { result -> ShareLinkFormatterFingerprint.resultOrThrow().let { result ->
result.mutableMethod.apply { result.mutableMethod.apply {
addInstructionsWithLabels( addInstructionsWithLabels(
0, 0,
@ -36,7 +36,7 @@ object SanitizeUrlQueryPatch : BaseBytecodePatch(
""", ExternalLabel("off", getInstruction(0)) """, ExternalLabel("off", getInstruction(0))
) )
} }
} ?: throw ShareLinkFormatterFingerprint.exception }
updateSettingsStatus("enableSanitizeUrlQuery") updateSettingsStatus("enableSanitizeUrlQuery")

View File

@ -15,9 +15,9 @@ import app.revanced.patches.reddit.utils.settings.fingerprints.AcknowledgementsL
import app.revanced.patches.reddit.utils.settings.fingerprints.OssLicensesMenuActivityOnCreateFingerprint import app.revanced.patches.reddit.utils.settings.fingerprints.OssLicensesMenuActivityOnCreateFingerprint
import app.revanced.patches.reddit.utils.settings.fingerprints.SettingsStatusLoadFingerprint import app.revanced.patches.reddit.utils.settings.fingerprints.SettingsStatusLoadFingerprint
import app.revanced.patches.shared.settings.fingerprints.SharedSettingFingerprint import app.revanced.patches.shared.settings.fingerprints.SharedSettingFingerprint
import app.revanced.util.exception
import app.revanced.util.getTargetIndex import app.revanced.util.getTargetIndex
import app.revanced.util.getWideLiteralInstructionIndex import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -47,7 +47,7 @@ object SettingsBytecodePatch : BytecodePatch(
/** /**
* Set SharedPrefCategory * Set SharedPrefCategory
*/ */
SharedSettingFingerprint.result?.let { SharedSettingFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val stringIndex = getTargetIndex(Opcode.CONST_STRING) val stringIndex = getTargetIndex(Opcode.CONST_STRING)
val stringRegister = getInstruction<OneRegisterInstruction>(stringIndex).registerA val stringRegister = getInstruction<OneRegisterInstruction>(stringIndex).registerA
@ -57,12 +57,12 @@ object SettingsBytecodePatch : BytecodePatch(
"const-string v$stringRegister, \"reddit_revanced\"" "const-string v$stringRegister, \"reddit_revanced\""
) )
} }
} ?: throw SharedSettingFingerprint.exception }
/** /**
* Replace settings label * Replace settings label
*/ */
AcknowledgementsLabelBuilderFingerprint.result?.let { AcknowledgementsLabelBuilderFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val insertIndex = val insertIndex =
getWideLiteralInstructionIndex(LabelAcknowledgements) + 3 getWideLiteralInstructionIndex(LabelAcknowledgements) + 3
@ -74,12 +74,12 @@ object SettingsBytecodePatch : BytecodePatch(
"const-string v$insertRegister, \"ReVanced Extended\"" "const-string v$insertRegister, \"ReVanced Extended\""
) )
} }
} ?: throw AcknowledgementsLabelBuilderFingerprint.exception }
/** /**
* Initialize settings activity * Initialize settings activity
*/ */
OssLicensesMenuActivityOnCreateFingerprint.result?.let { OssLicensesMenuActivityOnCreateFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.startIndex + 1 val insertIndex = it.scanResult.patternScanResult!!.startIndex + 1
@ -90,10 +90,9 @@ object SettingsBytecodePatch : BytecodePatch(
""" """
) )
} }
} ?: throw OssLicensesMenuActivityOnCreateFingerprint.exception }
settingsStatusLoadMethod = SettingsStatusLoadFingerprint.result?.mutableMethod settingsStatusLoadMethod = SettingsStatusLoadFingerprint.resultOrThrow().mutableMethod
?: throw SettingsStatusLoadFingerprint.exception
} }
} }

View File

@ -8,9 +8,9 @@ import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.shared.ads.fingerprints.MusicAdsFingerprint import app.revanced.patches.shared.ads.fingerprints.MusicAdsFingerprint
import app.revanced.patches.shared.ads.fingerprints.VideoAdsFingerprint import app.revanced.patches.shared.ads.fingerprints.VideoAdsFingerprint
import app.revanced.util.exception
import app.revanced.util.getWalkerMethod import app.revanced.util.getWalkerMethod
import app.revanced.util.indexOfFirstInstruction import app.revanced.util.indexOfFirstInstruction
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference import com.android.tools.smali.dexlib2.iface.reference.MethodReference
@ -25,7 +25,7 @@ abstract class BaseAdsPatch(
) )
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
MusicAdsFingerprint.result?.let { MusicAdsFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val targetIndex = indexOfFirstInstruction { val targetIndex = indexOfFirstInstruction {
val reference = ((this as? ReferenceInstruction)?.reference as? MethodReference) val reference = ((this as? ReferenceInstruction)?.reference as? MethodReference)
@ -44,9 +44,9 @@ abstract class BaseAdsPatch(
""" """
) )
} }
} ?: throw MusicAdsFingerprint.exception }
VideoAdsFingerprint.result?.let { VideoAdsFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
addInstructionsWithLabels( addInstructionsWithLabels(
0, """ 0, """
@ -57,6 +57,6 @@ abstract class BaseAdsPatch(
""", ExternalLabel("show_ads", getInstruction(0)) """, ExternalLabel("show_ads", getInstruction(0))
) )
} }
} ?: throw VideoAdsFingerprint.exception }
} }
} }

View File

@ -7,9 +7,9 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patches.shared.captions.fingerprints.StartVideoInformerFingerprint import app.revanced.patches.shared.captions.fingerprints.StartVideoInformerFingerprint
import app.revanced.patches.shared.captions.fingerprints.SubtitleTrackFingerprint import app.revanced.patches.shared.captions.fingerprints.SubtitleTrackFingerprint
import app.revanced.util.exception
import app.revanced.util.getWalkerMethod import app.revanced.util.getWalkerMethod
import app.revanced.util.indexOfFirstInstruction import app.revanced.util.indexOfFirstInstruction
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
@ -25,16 +25,16 @@ abstract class BaseAutoCaptionsPatch(
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
StartVideoInformerFingerprint.result?.let { StartVideoInformerFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
addInstruction( addInstruction(
0, 0,
"invoke-static {}, $classDescriptor->prefetchSubtitleTrack()V" "invoke-static {}, $classDescriptor->prefetchSubtitleTrack()V"
) )
} }
} ?: throw StartVideoInformerFingerprint.exception }
SubtitleTrackFingerprint.result?.let { SubtitleTrackFingerprint.resultOrThrow().let {
val targetMethod = it.getWalkerMethod(context, it.scanResult.patternScanResult!!.startIndex + 1) val targetMethod = it.getWalkerMethod(context, it.scanResult.patternScanResult!!.startIndex + 1)
targetMethod.apply { targetMethod.apply {
@ -51,7 +51,7 @@ abstract class BaseAutoCaptionsPatch(
""" """
) )
} }
} ?: throw SubtitleTrackFingerprint.exception }
} }
} }

View File

@ -16,7 +16,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.Instruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference import com.android.tools.smali.dexlib2.iface.reference.MethodReference
abstract class AbstractClientSpoofPatch( abstract class BaseClientSpoofPatch(
private val packageName: String private val packageName: String
) : BaseTransformInstructionsPatch<Instruction35cInfo>() { ) : BaseTransformInstructionsPatch<Instruction35cInfo>() {
override fun filterMap( override fun filterMap(

View File

@ -8,10 +8,10 @@ import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patches.shared.customspeed.fingerprints.SpeedArrayGeneratorFingerprint import app.revanced.patches.shared.customspeed.fingerprints.SpeedArrayGeneratorFingerprint
import app.revanced.patches.shared.customspeed.fingerprints.SpeedLimiterFallBackFingerprint import app.revanced.patches.shared.customspeed.fingerprints.SpeedLimiterFallBackFingerprint
import app.revanced.patches.shared.customspeed.fingerprints.SpeedLimiterFingerprint import app.revanced.patches.shared.customspeed.fingerprints.SpeedLimiterFingerprint
import app.revanced.util.exception
import app.revanced.util.getTargetIndexWithFieldReferenceType import app.revanced.util.getTargetIndexWithFieldReferenceType
import app.revanced.util.getTargetIndexWithMethodReferenceName import app.revanced.util.getTargetIndexWithMethodReferenceName
import app.revanced.util.indexOfFirstInstruction import app.revanced.util.indexOfFirstInstruction
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.NarrowLiteralInstruction import com.android.tools.smali.dexlib2.iface.instruction.NarrowLiteralInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -25,9 +25,9 @@ abstract class BaseCustomPlaybackSpeedPatch(
) )
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
SpeedArrayGeneratorFingerprint.result?.let { result -> SpeedArrayGeneratorFingerprint.resultOrThrow().let {
result.mutableMethod.apply { it.mutableMethod.apply {
val targetIndex = result.scanResult.patternScanResult!!.startIndex val targetIndex = it.scanResult.patternScanResult!!.startIndex
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
addInstructions( addInstructions(
@ -57,13 +57,11 @@ abstract class BaseCustomPlaybackSpeedPatch(
""" """
) )
} }
} ?: throw SpeedArrayGeneratorFingerprint.exception }
val speedLimiterParentResult = SpeedLimiterFallBackFingerprint.result val speedLimiterParentResult = SpeedLimiterFallBackFingerprint.resultOrThrow()
?: throw SpeedLimiterFallBackFingerprint.exception
SpeedLimiterFingerprint.resolve(context, speedLimiterParentResult.classDef) SpeedLimiterFingerprint.resolve(context, speedLimiterParentResult.classDef)
val speedLimiterResult = SpeedLimiterFingerprint.result val speedLimiterResult = SpeedLimiterFingerprint.resultOrThrow()
?: throw SpeedLimiterFingerprint.exception
arrayOf( arrayOf(
speedLimiterParentResult, speedLimiterParentResult,

View File

@ -7,9 +7,9 @@ import app.revanced.patcher.fingerprint.MethodFingerprint
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.shared.dialog.fingerprints.CreateDialogFingerprint import app.revanced.patches.shared.dialog.fingerprints.CreateDialogFingerprint
import app.revanced.util.exception
import app.revanced.util.getTargetIndexWithMethodReferenceName import app.revanced.util.getTargetIndexWithMethodReferenceName
import app.revanced.util.getWalkerMethod import app.revanced.util.getWalkerMethod
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
abstract class BaseViewerDiscretionDialogPatch( abstract class BaseViewerDiscretionDialogPatch(
@ -38,15 +38,14 @@ abstract class BaseViewerDiscretionDialogPatch(
} }
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
CreateDialogFingerprint.result?.mutableMethod?.invoke(false) CreateDialogFingerprint.resultOrThrow().mutableMethod.invoke(false)
?: throw CreateDialogFingerprint.exception
if (additionalFingerprints.isNotEmpty()) { if (additionalFingerprints.isNotEmpty()) {
additionalFingerprints.forEach { fingerprint -> additionalFingerprints.forEach { fingerprint ->
fingerprint.result?.let { fingerprint.resultOrThrow().let {
it.getWalkerMethod(context, it.scanResult.patternScanResult!!.endIndex - 1) it.getWalkerMethod(context, it.scanResult.patternScanResult!!.endIndex - 1)
.invoke(true) .invoke(true)
} ?: throw fingerprint.exception }
} }
} }

View File

@ -6,8 +6,8 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.shared.drawable.fingerprints.DrawableFingerprint import app.revanced.patches.shared.drawable.fingerprints.DrawableFingerprint
import app.revanced.util.exception
import app.revanced.util.getTargetIndexWithMethodReferenceNameReversed import app.revanced.util.getTargetIndexWithMethodReferenceNameReversed
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
object DrawableColorPatch : BytecodePatch( object DrawableColorPatch : BytecodePatch(
@ -15,11 +15,11 @@ object DrawableColorPatch : BytecodePatch(
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
DrawableFingerprint.result?.mutableMethod?.apply { DrawableFingerprint.resultOrThrow().mutableMethod?.apply {
insertMethod = this insertMethod = this
insertIndex = getTargetIndexWithMethodReferenceNameReversed("setColor") insertIndex = getTargetIndexWithMethodReferenceNameReversed("setColor")
insertRegister = getInstruction<FiveRegisterInstruction>(insertIndex).registerD insertRegister = getInstruction<FiveRegisterInstruction>(insertIndex).registerD
} ?: throw DrawableFingerprint.exception }
} }
private var offset = 0 private var offset = 0

View File

@ -7,15 +7,21 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstructions
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patcher.fingerprint.MethodFingerprint import app.revanced.patcher.fingerprint.MethodFingerprint
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patches.shared.gms.fingerprints.*
import app.revanced.patches.shared.gms.fingerprints.GmsCoreSupportFingerprint.GET_GMS_CORE_VENDOR_GROUP_ID_METHOD_NAME
import app.revanced.patches.shared.gms.BaseGmsCoreSupportPatch.Constants.ACTIONS import app.revanced.patches.shared.gms.BaseGmsCoreSupportPatch.Constants.ACTIONS
import app.revanced.patches.shared.gms.BaseGmsCoreSupportPatch.Constants.AUTHORITIES import app.revanced.patches.shared.gms.BaseGmsCoreSupportPatch.Constants.AUTHORITIES
import app.revanced.patches.shared.gms.BaseGmsCoreSupportPatch.Constants.PERMISSIONS import app.revanced.patches.shared.gms.BaseGmsCoreSupportPatch.Constants.PERMISSIONS
import app.revanced.patches.shared.gms.fingerprints.CastContextFetchFingerprint
import app.revanced.patches.shared.gms.fingerprints.CastDynamiteModuleFingerprint
import app.revanced.patches.shared.gms.fingerprints.CastDynamiteModuleV2Fingerprint
import app.revanced.patches.shared.gms.fingerprints.GmsCoreSupportFingerprint
import app.revanced.patches.shared.gms.fingerprints.GmsCoreSupportFingerprint.GET_GMS_CORE_VENDOR_GROUP_ID_METHOD_NAME
import app.revanced.patches.shared.gms.fingerprints.GooglePlayUtilityFingerprint
import app.revanced.patches.shared.gms.fingerprints.PrimeMethodFingerprint
import app.revanced.patches.shared.gms.fingerprints.ServiceCheckFingerprint
import app.revanced.patches.shared.integrations.Constants.INTEGRATIONS_PATH import app.revanced.patches.shared.integrations.Constants.INTEGRATIONS_PATH
import app.revanced.patches.shared.packagename.PackageNamePatch import app.revanced.patches.shared.packagename.PackageNamePatch
import app.revanced.util.exception
import app.revanced.util.getReference import app.revanced.util.getReference
import app.revanced.util.resultOrThrow
import app.revanced.util.returnEarly import app.revanced.util.returnEarly
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction21c import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction21c
@ -98,17 +104,16 @@ abstract class BaseGmsCoreSupportPatch(
).returnEarly() ).returnEarly()
// Verify GmsCore is installed and whitelisted for power optimizations and background usage. // Verify GmsCore is installed and whitelisted for power optimizations and background usage.
mainActivityOnCreateFingerprint.result?.mutableMethod?.addInstructions( mainActivityOnCreateFingerprint.resultOrThrow().mutableMethod.addInstructions(
1, // Hack to not disturb other patches (such as the YTMusic integrations patch). 1, // Hack to not disturb other patches (such as the YTMusic integrations patch).
"invoke-static/range { p0 .. p0 }, $INTEGRATIONS_PATH/patches/GmsCoreSupport;->" + "invoke-static/range { p0 .. p0 }, $INTEGRATIONS_PATH/patches/GmsCoreSupport;->" +
"checkGmsCore(Landroid/content/Context;)V", "checkGmsCore(Landroid/content/Context;)V",
) ?: throw mainActivityOnCreateFingerprint.exception )
// Change the vendor of GmsCore in ReVanced Integrations. // Change the vendor of GmsCore in ReVanced Integrations.
GmsCoreSupportFingerprint.result?.mutableClass?.methods GmsCoreSupportFingerprint.resultOrThrow().mutableClass.methods
?.single { it.name == GET_GMS_CORE_VENDOR_GROUP_ID_METHOD_NAME } .single { it.name == GET_GMS_CORE_VENDOR_GROUP_ID_METHOD_NAME }
?.replaceInstruction(0, "const-string v0, \"$gmsCoreVendorGroupId\"") .replaceInstruction(0, "const-string v0, \"$gmsCoreVendorGroupId\"")
?: throw GmsCoreSupportFingerprint.exception
} }
private fun BytecodeContext.transformStringReferences(transform: (str: String) -> String?) = classes.forEach { private fun BytecodeContext.transformStringReferences(transform: (str: String) -> String?) = classes.forEach {
@ -193,7 +198,7 @@ abstract class BaseGmsCoreSupportPatch(
} }
private fun transformPrimeMethod(packageName: String) { private fun transformPrimeMethod(packageName: String) {
PrimeMethodFingerprint.result?.mutableMethod?.apply { PrimeMethodFingerprint.resultOrThrow().mutableMethod.apply {
var register = 2 var register = 2
val index = getInstructions().indexOfFirst { val index = getInstructions().indexOfFirst {
@ -204,7 +209,7 @@ abstract class BaseGmsCoreSupportPatch(
} }
replaceInstruction(index, "const-string v$register, \"$packageName\"") replaceInstruction(index, "const-string v$register, \"$packageName\"")
} ?: throw PrimeMethodFingerprint.exception }
} }
/** /**

View File

@ -7,6 +7,7 @@ import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.PatchException
import app.revanced.patches.shared.integrations.BaseIntegrationsPatch.IntegrationsFingerprint.IRegisterResolver import app.revanced.patches.shared.integrations.BaseIntegrationsPatch.IntegrationsFingerprint.IRegisterResolver
import app.revanced.patches.shared.integrations.Constants.INTEGRATIONS_UTILS_CLASS_DESCRIPTOR import app.revanced.patches.shared.integrations.Constants.INTEGRATIONS_UTILS_CLASS_DESCRIPTOR
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.ClassDef import com.android.tools.smali.dexlib2.iface.ClassDef
import com.android.tools.smali.dexlib2.iface.Method import com.android.tools.smali.dexlib2.iface.Method
@ -83,16 +84,16 @@ abstract class BaseIntegrationsPatch(
) )
fun invoke(integrationsDescriptor: String) { fun invoke(integrationsDescriptor: String) {
result?.mutableMethod?.let { method -> resultOrThrow().mutableMethod.let { method ->
val insertIndex = insertIndexResolver(method) val insertIndex = insertIndexResolver(method)
val contextRegister = contextRegisterResolver(method) val contextRegister = contextRegisterResolver(method)
method.addInstruction( method.addInstruction(
insertIndex, insertIndex,
"invoke-static/range { v$contextRegister .. v$contextRegister }, " + "invoke-static/range { v$contextRegister .. v$contextRegister }, " +
"$integrationsDescriptor->setContext(Landroid/content/Context;)V", "$integrationsDescriptor->setContext(Landroid/content/Context;)V",
) )
} ?: throw PatchException("Could not find hook target fingerprint.") }
} }
interface IHookInsertIndexResolver : (Method) -> Int { interface IHookInsertIndexResolver : (Method) -> Int {

View File

@ -12,11 +12,11 @@ import app.revanced.patches.shared.integrations.Constants.COMPONENTS_PATH
import app.revanced.patches.shared.litho.fingerprints.LithoFilterPatchConstructorFingerprint import app.revanced.patches.shared.litho.fingerprints.LithoFilterPatchConstructorFingerprint
import app.revanced.patches.shared.litho.fingerprints.PathBuilderFingerprint import app.revanced.patches.shared.litho.fingerprints.PathBuilderFingerprint
import app.revanced.patches.shared.litho.fingerprints.SetByteBufferFingerprint import app.revanced.patches.shared.litho.fingerprints.SetByteBufferFingerprint
import app.revanced.util.exception
import app.revanced.util.getEmptyStringInstructionIndex import app.revanced.util.getEmptyStringInstructionIndex
import app.revanced.util.getTargetIndex import app.revanced.util.getTargetIndex
import app.revanced.util.getTargetIndexReversed import app.revanced.util.getTargetIndexReversed
import app.revanced.util.getTargetIndexWithFieldReferenceType import app.revanced.util.getTargetIndexWithFieldReferenceType
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction35c import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction35c
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
@ -44,7 +44,7 @@ object LithoFilterPatch : BytecodePatch(
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
SetByteBufferFingerprint.result?.let { SetByteBufferFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val insertIndex = getTargetIndex(Opcode.IF_EQZ) + 1 val insertIndex = getTargetIndex(Opcode.IF_EQZ) + 1
@ -53,9 +53,9 @@ object LithoFilterPatch : BytecodePatch(
"invoke-static { p2 }, $INTEGRATIONS_LITHO_FILER_CLASS_DESCRIPTOR->setProtoBuffer(Ljava/nio/ByteBuffer;)V" "invoke-static { p2 }, $INTEGRATIONS_LITHO_FILER_CLASS_DESCRIPTOR->setProtoBuffer(Ljava/nio/ByteBuffer;)V"
) )
} }
} ?: throw SetByteBufferFingerprint.exception }
PathBuilderFingerprint.result?.let { PathBuilderFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val emptyComponentMethodIndex = it.scanResult.patternScanResult!!.startIndex + 1 val emptyComponentMethodIndex = it.scanResult.patternScanResult!!.startIndex + 1
val emptyComponentMethodReference = val emptyComponentMethodReference =
@ -89,9 +89,9 @@ object LithoFilterPatch : BytecodePatch(
""", ExternalLabel("filter", getInstruction(insertIndex)) """, ExternalLabel("filter", getInstruction(insertIndex))
) )
} }
} ?: throw PathBuilderFingerprint.exception }
LithoFilterPatchConstructorFingerprint.result?.let { LithoFilterPatchConstructorFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
removeInstructions(0, 6) removeInstructions(0, 6)
@ -106,7 +106,7 @@ object LithoFilterPatch : BytecodePatch(
) )
} }
} }
} ?: throw LithoFilterPatchConstructorFingerprint.exception }
} }
override fun close() = LithoFilterPatchConstructorFingerprint.result!! override fun close() = LithoFilterPatchConstructorFingerprint.result!!

View File

@ -7,8 +7,8 @@ import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.shared.opus.fingerprints.CodecReferenceFingerprint import app.revanced.patches.shared.opus.fingerprints.CodecReferenceFingerprint
import app.revanced.patches.shared.opus.fingerprints.CodecSelectorFingerprint import app.revanced.patches.shared.opus.fingerprints.CodecSelectorFingerprint
import app.revanced.util.exception
import app.revanced.util.getTargetIndexWithReference import app.revanced.util.getTargetIndexWithReference
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.reference.Reference import com.android.tools.smali.dexlib2.iface.reference.Reference
@ -25,14 +25,14 @@ abstract class BaseOpusCodecsPatch(
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
CodecReferenceFingerprint.result?.let { CodecReferenceFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val targetIndex = getTargetIndexWithReference("Ljava/util/Set;") val targetIndex = getTargetIndexWithReference("Ljava/util/Set;")
targetReference = getInstruction<ReferenceInstruction>(targetIndex).reference targetReference = getInstruction<ReferenceInstruction>(targetIndex).reference
} }
} ?: throw CodecReferenceFingerprint.exception }
CodecSelectorFingerprint.result?.let { CodecSelectorFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.endIndex val targetIndex = it.scanResult.patternScanResult!!.endIndex
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
@ -47,6 +47,6 @@ abstract class BaseOpusCodecsPatch(
""", ExternalLabel("mp4a", getInstruction(targetIndex + 1)) """, ExternalLabel("mp4a", getInstruction(targetIndex + 1))
) )
} }
} ?: throw CodecSelectorFingerprint.exception }
} }
} }

View File

@ -6,9 +6,9 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patches.shared.spoofappversion.fingerprints.ClientInfoFingerprint import app.revanced.patches.shared.spoofappversion.fingerprints.ClientInfoFingerprint
import app.revanced.patches.shared.spoofappversion.fingerprints.ClientInfoParentFingerprint import app.revanced.patches.shared.spoofappversion.fingerprints.ClientInfoParentFingerprint
import app.revanced.util.exception
import app.revanced.util.getTargetIndexReversed import app.revanced.util.getTargetIndexReversed
import app.revanced.util.getTargetIndexWithFieldReferenceName import app.revanced.util.getTargetIndexWithFieldReferenceName
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
@ -19,10 +19,10 @@ abstract class BaseSpoofAppVersionPatch(
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
ClientInfoParentFingerprint.result?.let { parentResult -> ClientInfoParentFingerprint.resultOrThrow().let { parentResult ->
ClientInfoFingerprint.resolve(context, parentResult.classDef) ClientInfoFingerprint.resolve(context, parentResult.classDef)
ClientInfoFingerprint.result?.let { ClientInfoFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val versionIndex = getTargetIndexWithFieldReferenceName("RELEASE") + 1 val versionIndex = getTargetIndexWithFieldReferenceName("RELEASE") + 1
val insertIndex = getTargetIndexReversed(versionIndex, Opcode.IPUT_OBJECT) val insertIndex = getTargetIndexReversed(versionIndex, Opcode.IPUT_OBJECT)
@ -35,8 +35,8 @@ abstract class BaseSpoofAppVersionPatch(
""" """
) )
} }
} ?: throw ClientInfoFingerprint.exception }
} ?: throw ClientInfoParentFingerprint.exception }
} }
} }

View File

@ -5,7 +5,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.fingerprint.MethodFingerprint import app.revanced.patcher.fingerprint.MethodFingerprint
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.util.exception import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
abstract class BaseSanitizeUrlQueryPatch( abstract class BaseSanitizeUrlQueryPatch(
@ -19,7 +19,7 @@ abstract class BaseSanitizeUrlQueryPatch(
} }
) { ) {
private fun MethodFingerprint.invoke() { private fun MethodFingerprint.invoke() {
result?.let { resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.startIndex val targetIndex = it.scanResult.patternScanResult!!.startIndex
val targetRegister = getInstruction<TwoRegisterInstruction>(targetIndex).registerA val targetRegister = getInstruction<TwoRegisterInstruction>(targetIndex).registerA
@ -31,7 +31,7 @@ abstract class BaseSanitizeUrlQueryPatch(
""" """
) )
} }
} ?: throw exception }
} }
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {

View File

@ -1,7 +1,7 @@
package app.revanced.patches.shared.translations package app.revanced.patches.shared.translations
import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.data.ResourceContext
import app.revanced.util.classLoader import app.revanced.util.inputStreamFromBundledResource
import java.nio.file.Files import java.nio.file.Files
import java.nio.file.StandardCopyOption import java.nio.file.StandardCopyOption
@ -13,12 +13,10 @@ object TranslationsUtils {
) { ) {
languageArray.forEach { language -> languageArray.forEach { language ->
val directory = "values-$language-v21" val directory = "values-$language-v21"
val relativePath = "$language/strings.xml"
this["res/$directory"].mkdir() this["res/$directory"].mkdir()
Files.copy( Files.copy(
classLoader.getResourceAsStream("$sourceDirectory/translations/$relativePath")!!, inputStreamFromBundledResource("$sourceDirectory/translations", "$language/strings.xml")!!,
this["res"].resolve("$directory/strings.xml").toPath(), this["res"].resolve("$directory/strings.xml").toPath(),
StandardCopyOption.REPLACE_EXISTING StandardCopyOption.REPLACE_EXISTING
) )

View File

@ -12,8 +12,8 @@ import app.revanced.patches.youtube.ads.fullscreen.fingerprints.ShowDialogComman
import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.InterstitialsContainer import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.InterstitialsContainer
import app.revanced.util.exception
import app.revanced.util.getWideLiteralInstructionIndex import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Patch(dependencies = [SharedResourceIdPatch::class]) @Patch(dependencies = [SharedResourceIdPatch::class])
@ -31,7 +31,7 @@ object FullscreenAdsPatch : BytecodePatch(
* Hides fullscreen ads * Hides fullscreen ads
* Non-litho view, used in some old clients. * Non-litho view, used in some old clients.
*/ */
InterstitialsContainerFingerprint.result?.let { InterstitialsContainerFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val targetIndex = getWideLiteralInstructionIndex(InterstitialsContainer) + 2 val targetIndex = getWideLiteralInstructionIndex(InterstitialsContainer) + 2
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
@ -41,13 +41,13 @@ object FullscreenAdsPatch : BytecodePatch(
"invoke-static {v$targetRegister}, $FILTER_CLASS_DESCRIPTOR->hideFullscreenAds(Landroid/view/View;)V" "invoke-static {v$targetRegister}, $FILTER_CLASS_DESCRIPTOR->hideFullscreenAds(Landroid/view/View;)V"
) )
} }
} ?: throw InterstitialsContainerFingerprint.exception }
/** /**
* Hides fullscreen ads * Hides fullscreen ads
* Litho view, used in 'ShowDialogCommandOuterClass' in innertube * Litho view, used in 'ShowDialogCommandOuterClass' in innertube
*/ */
ShowDialogCommandFingerprint.result?.let { ShowDialogCommandFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
// In this method, custom dialog is created and shown. // In this method, custom dialog is created and shown.
// There were no issues despite adding “return-void” to the first index. // There were no issues despite adding “return-void” to the first index.
@ -94,6 +94,6 @@ object FullscreenAdsPatch : BytecodePatch(
// """ // """
// ) // )
} }
} ?: throw ShowDialogCommandFingerprint.exception }
} }
} }

View File

@ -7,7 +7,7 @@ import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.youtube.ads.getpremium.fingerprints.CompactYpcOfferModuleViewFingerprint import app.revanced.patches.youtube.ads.getpremium.fingerprints.CompactYpcOfferModuleViewFingerprint
import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH
import app.revanced.util.exception import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
object GetPremiumPatch : BytecodePatch( object GetPremiumPatch : BytecodePatch(
@ -18,7 +18,7 @@ object GetPremiumPatch : BytecodePatch(
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
CompactYpcOfferModuleViewFingerprint.result?.let { CompactYpcOfferModuleViewFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val startIndex = it.scanResult.patternScanResult!!.startIndex val startIndex = it.scanResult.patternScanResult!!.startIndex
val measuredWidthRegister = val measuredWidthRegister =
@ -38,7 +38,7 @@ object GetPremiumPatch : BytecodePatch(
""", ExternalLabel("show", getInstruction(startIndex + 2)) """, ExternalLabel("show", getInstruction(startIndex + 2))
) )
} }
} ?: throw CompactYpcOfferModuleViewFingerprint.exception }
} }
} }

View File

@ -18,8 +18,8 @@ import app.revanced.patches.youtube.utils.integrations.Constants.COMPATIBLE_PACK
import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.patches.youtube.utils.settings.SettingsPatch.contexts import app.revanced.patches.youtube.utils.settings.SettingsPatch.contexts
import app.revanced.util.copyXmlNode import app.revanced.util.copyXmlNode
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.builder.MutableMethodImplementation import com.android.tools.smali.dexlib2.builder.MutableMethodImplementation
@ -90,11 +90,8 @@ object AlternativeThumbnailsPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
fun MethodFingerprint.getResultOrThrow() =
result ?: throw exception
fun MethodFingerprint.alsoResolve(fingerprint: MethodFingerprint) = fun MethodFingerprint.alsoResolve(fingerprint: MethodFingerprint) =
also { resolve(context, fingerprint.getResultOrThrow().classDef) }.getResultOrThrow() also { resolve(context, fingerprint.resultOrThrow().classDef) }.resultOrThrow()
fun MethodFingerprint.resolveAndLetMutableMethod( fun MethodFingerprint.resolveAndLetMutableMethod(
fingerprint: MethodFingerprint, fingerprint: MethodFingerprint,
@ -118,7 +115,7 @@ object AlternativeThumbnailsPatch : BaseBytecodePatch(
// The URL is required for the failure callback hook, but the URL field is obfuscated. // The URL is required for the failure callback hook, but the URL field is obfuscated.
// Add a helper get method that returns the URL field. // Add a helper get method that returns the URL field.
RequestFingerprint.getResultOrThrow().apply { RequestFingerprint.resultOrThrow().apply {
// The url is the only string field that is set inside the constructor. // The url is the only string field that is set inside the constructor.
val urlFieldInstruction = mutableMethod.getInstructions().first { val urlFieldInstruction = mutableMethod.getInstructions().first {
if (it.opcode != Opcode.IPUT_OBJECT) if (it.opcode != Opcode.IPUT_OBJECT)

View File

@ -13,11 +13,11 @@ import app.revanced.patches.youtube.utils.integrations.Constants.COMPATIBLE_PACK
import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getTargetIndex import app.revanced.util.getTargetIndex
import app.revanced.util.getWalkerMethod import app.revanced.util.getWalkerMethod
import app.revanced.util.getWideLiteralInstructionIndex import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -41,7 +41,7 @@ object CommentComponentPatch : BaseBytecodePatch(
"$COMPONENTS_PATH/CommentsFilter;" "$COMPONENTS_PATH/CommentsFilter;"
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
ShortsLiveStreamEmojiPickerOpacityFingerprint.result?.let { ShortsLiveStreamEmojiPickerOpacityFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val insertIndex = implementation!!.instructions.size - 1 val insertIndex = implementation!!.instructions.size - 1
val insertRegister= getInstruction<OneRegisterInstruction>(insertIndex).registerA val insertRegister= getInstruction<OneRegisterInstruction>(insertIndex).registerA
@ -51,9 +51,9 @@ object CommentComponentPatch : BaseBytecodePatch(
"invoke-static {v$insertRegister}, $BOTTOM_PLAYER_CLASS_DESCRIPTOR->changeEmojiPickerOpacity(Landroid/widget/ImageView;)V" "invoke-static {v$insertRegister}, $BOTTOM_PLAYER_CLASS_DESCRIPTOR->changeEmojiPickerOpacity(Landroid/widget/ImageView;)V"
) )
} }
} ?: throw ShortsLiveStreamEmojiPickerOpacityFingerprint.exception }
ShortsLiveStreamEmojiPickerOnClickListenerFingerprint.result?.let { parentResult -> ShortsLiveStreamEmojiPickerOnClickListenerFingerprint.resultOrThrow().let { parentResult ->
parentResult.mutableMethod.apply { parentResult.mutableMethod.apply {
val emojiPickerEndpointIndex = getWideLiteralInstructionIndex(126326492) val emojiPickerEndpointIndex = getWideLiteralInstructionIndex(126326492)
val emojiPickerOnClickListenerIndex = getTargetIndex(emojiPickerEndpointIndex, Opcode.INVOKE_DIRECT) val emojiPickerOnClickListenerIndex = getTargetIndex(emojiPickerEndpointIndex, Opcode.INVOKE_DIRECT)
@ -77,7 +77,7 @@ object CommentComponentPatch : BaseBytecodePatch(
context, context,
parentResult.classDef parentResult.classDef
) )
}.result?.let { }.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.startIndex val insertIndex = it.scanResult.patternScanResult!!.startIndex
val insertInstruction = getInstruction<FiveRegisterInstruction>(insertIndex) val insertInstruction = getInstruction<FiveRegisterInstruction>(insertIndex)

View File

@ -12,8 +12,8 @@ import app.revanced.patches.youtube.utils.integrations.Constants.COMPATIBLE_PACK
import app.revanced.patches.youtube.utils.integrations.Constants.FLYOUT_PANEL_CLASS_DESCRIPTOR import app.revanced.patches.youtube.utils.integrations.Constants.FLYOUT_PANEL_CLASS_DESCRIPTOR
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c
@ -40,8 +40,7 @@ object FeedFlyoutPanelPatch : BaseBytecodePatch(
* Phone * Phone
*/ */
val bottomSheetMenuItemBuilderResult = BottomSheetMenuItemBuilderLegacyFingerprint.result val bottomSheetMenuItemBuilderResult = BottomSheetMenuItemBuilderLegacyFingerprint.result
?: BottomSheetMenuItemBuilderFingerprint.result ?: BottomSheetMenuItemBuilderFingerprint.resultOrThrow()
?: throw BottomSheetMenuItemBuilderFingerprint.exception
bottomSheetMenuItemBuilderResult.let { bottomSheetMenuItemBuilderResult.let {
it.mutableMethod.apply { it.mutableMethod.apply {
@ -65,7 +64,7 @@ object FeedFlyoutPanelPatch : BaseBytecodePatch(
/** /**
* Tablet * Tablet
*/ */
ContextualMenuItemBuilderFingerprint.result?.let { ContextualMenuItemBuilderFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.startIndex + 1 val targetIndex = it.scanResult.patternScanResult!!.startIndex + 1
val targetInstruction = getInstruction<Instruction35c>(targetIndex) val targetInstruction = getInstruction<Instruction35c>(targetIndex)
@ -81,7 +80,7 @@ object FeedFlyoutPanelPatch : BaseBytecodePatch(
"$FLYOUT_PANEL_CLASS_DESCRIPTOR->hideFeedFlyoutPanel(Landroid/widget/TextView;Ljava/lang/CharSequence;)V" "$FLYOUT_PANEL_CLASS_DESCRIPTOR->hideFeedFlyoutPanel(Landroid/widget/TextView;Ljava/lang/CharSequence;)V"
) )
} }
} ?: throw ContextualMenuItemBuilderFingerprint.exception }
/** /**
* Add settings * Add settings

View File

@ -15,11 +15,11 @@ import app.revanced.patches.youtube.utils.integrations.Constants.FLYOUT_PANEL_CL
import app.revanced.patches.youtube.utils.recyclerview.BottomSheetRecyclerViewPatch import app.revanced.patches.youtube.utils.recyclerview.BottomSheetRecyclerViewPatch
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getReference import app.revanced.util.getReference
import app.revanced.util.getTargetIndex import app.revanced.util.getTargetIndex
import app.revanced.util.indexOfFirstInstruction import app.revanced.util.indexOfFirstInstruction
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
@ -49,10 +49,9 @@ object OldQualityLayoutPatch : BaseBytecodePatch(
/** /**
* Non-litho view, used in old clients and Shorts. * Non-litho view, used in old clients and Shorts.
*/ */
val videoQualityClass = VideoQualitySetterFingerprint.result?.mutableMethod?.definingClass val videoQualityClass = VideoQualitySetterFingerprint.resultOrThrow().mutableMethod.definingClass
?: throw VideoQualitySetterFingerprint.exception
QualityMenuViewInflateFingerprint.result?.let { QualityMenuViewInflateFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.endIndex val insertIndex = it.scanResult.patternScanResult!!.endIndex
val insertRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA val insertRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
@ -82,7 +81,7 @@ object OldQualityLayoutPatch : BaseBytecodePatch(
""", ExternalLabel("show", getInstruction(jumpIndex)) """, ExternalLabel("show", getInstruction(jumpIndex))
) )
} ?: throw PatchException("Failed to find onItemClick method") } ?: throw PatchException("Failed to find onItemClick method")
} ?: throw QualityMenuViewInflateFingerprint.exception }
/** /**
* Litho view * Litho view

View File

@ -15,7 +15,7 @@ import app.revanced.patches.youtube.flyoutpanel.oldspeedlayout.fingerprints.Play
import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH
import app.revanced.patches.youtube.utils.integrations.Constants.VIDEO_PATH import app.revanced.patches.youtube.utils.integrations.Constants.VIDEO_PATH
import app.revanced.patches.youtube.utils.recyclerview.BottomSheetRecyclerViewPatch import app.revanced.patches.youtube.utils.recyclerview.BottomSheetRecyclerViewPatch
import app.revanced.util.exception import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.immutable.ImmutableField import com.android.tools.smali.dexlib2.immutable.ImmutableField
@ -45,7 +45,7 @@ object OldSpeedLayoutPatch : BytecodePatch(
/** /**
* Input 'playbackRateBottomSheetClass' in FlyoutPanelPatch. * Input 'playbackRateBottomSheetClass' in FlyoutPanelPatch.
*/ */
PlaybackRateBottomSheetClassFingerprint.result?.let { PlaybackRateBottomSheetClassFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
playbackRateBottomSheetClass = definingClass playbackRateBottomSheetClass = definingClass
playbackRateBottomSheetBuilderMethod = playbackRateBottomSheetBuilderMethod =
@ -58,13 +58,13 @@ object OldSpeedLayoutPatch : BytecodePatch(
"sput-object p0, $INTEGRATIONS_CLASS_DESCRIPTOR->playbackRateBottomSheetClass:$playbackRateBottomSheetClass" "sput-object p0, $INTEGRATIONS_CLASS_DESCRIPTOR->playbackRateBottomSheetClass:$playbackRateBottomSheetClass"
) )
} }
} ?: throw PlaybackRateBottomSheetClassFingerprint.exception }
/** /**
* Create a static field in the patch * Create a static field in the patch
* Add a call the Playback Speed Bottom Sheet Fragment method * Add a call the Playback Speed Bottom Sheet Fragment method
*/ */
CustomPlaybackSpeedIntegrationsFingerprint.result?.let { CustomPlaybackSpeedIntegrationsFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
// Create a static field 'playbackRateBottomSheetClass' in FlyoutPanelPatch. // Create a static field 'playbackRateBottomSheetClass' in FlyoutPanelPatch.
it.mutableClass.staticFields.add( it.mutableClass.staticFields.add(
@ -92,7 +92,7 @@ object OldSpeedLayoutPatch : BytecodePatch(
""" """
) )
} }
} ?: throw CustomPlaybackSpeedIntegrationsFingerprint.exception }
BottomSheetRecyclerViewPatch.injectCall("$INTEGRATIONS_CLASS_DESCRIPTOR->onFlyoutMenuCreate(Landroid/support/v7/widget/RecyclerView;)V") BottomSheetRecyclerViewPatch.injectCall("$INTEGRATIONS_CLASS_DESCRIPTOR->onFlyoutMenuCreate(Landroid/support/v7/widget/RecyclerView;)V")

View File

@ -15,12 +15,12 @@ import app.revanced.patches.youtube.flyoutpanel.toggle.fingerprints.StableVolume
import app.revanced.patches.youtube.utils.integrations.Constants.COMPATIBLE_PACKAGE import app.revanced.patches.youtube.utils.integrations.Constants.COMPATIBLE_PACKAGE
import app.revanced.patches.youtube.utils.integrations.Constants.FLYOUT_PANEL_CLASS_DESCRIPTOR import app.revanced.patches.youtube.utils.integrations.Constants.FLYOUT_PANEL_CLASS_DESCRIPTOR
import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getStringInstructionIndex import app.revanced.util.getStringInstructionIndex
import app.revanced.util.getTargetIndex import app.revanced.util.getTargetIndex
import app.revanced.util.getTargetIndexReversed import app.revanced.util.getTargetIndexReversed
import app.revanced.util.indexOfFirstInstruction import app.revanced.util.indexOfFirstInstruction
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -41,15 +41,11 @@ object ChangeTogglePatch : BaseBytecodePatch(
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
val additionalSettingsConfigResult = AdditionalSettingsConfigFingerprint.result val additionalSettingsConfigMethod = AdditionalSettingsConfigFingerprint.resultOrThrow().mutableMethod
?: throw AdditionalSettingsConfigFingerprint.exception
val additionalSettingsConfigMethod = additionalSettingsConfigResult.mutableMethod
val methodToCall = additionalSettingsConfigMethod.definingClass + "->" + additionalSettingsConfigMethod.name + "()Z" val methodToCall = additionalSettingsConfigMethod.definingClass + "->" + additionalSettingsConfigMethod.name + "()Z"
// Resolves fingerprints // Resolves fingerprints
val playbackLoopOnClickListenerResult = PlaybackLoopOnClickListenerFingerprint.result val playbackLoopOnClickListenerResult = PlaybackLoopOnClickListenerFingerprint.resultOrThrow()
?: throw PlaybackLoopOnClickListenerFingerprint.exception
PlaybackLoopInitFingerprint.resolve(context, playbackLoopOnClickListenerResult.classDef) PlaybackLoopInitFingerprint.resolve(context, playbackLoopOnClickListenerResult.classDef)
arrayOf( arrayOf(
@ -79,7 +75,7 @@ object ChangeTogglePatch : BaseBytecodePatch(
fingerprint: MethodFingerprint, fingerprint: MethodFingerprint,
methodToCall: String methodToCall: String
) { ) {
fingerprint.result?.let { fingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val referenceIndex = indexOfFirstInstruction { val referenceIndex = indexOfFirstInstruction {
opcode == Opcode.INVOKE_VIRTUAL opcode == Opcode.INVOKE_VIRTUAL
@ -102,12 +98,11 @@ object ChangeTogglePatch : BaseBytecodePatch(
throw PatchException("Target reference'$methodToCall' was not found in ${this.javaClass.simpleName}.") throw PatchException("Target reference'$methodToCall' was not found in ${this.javaClass.simpleName}.")
} }
} }
} ?: throw fingerprint.exception }
} }
private fun injectCinematicLightingMethod() { private fun injectCinematicLightingMethod() {
val stableVolumeMethod = StableVolumeFingerprint.result?.mutableMethod val stableVolumeMethod = StableVolumeFingerprint.resultOrThrow().mutableMethod
?: throw StableVolumeFingerprint.exception
val stringReferenceIndex = stableVolumeMethod.indexOfFirstInstruction { val stringReferenceIndex = stableVolumeMethod.indexOfFirstInstruction {
opcode == Opcode.INVOKE_VIRTUAL opcode == Opcode.INVOKE_VIRTUAL
@ -118,7 +113,7 @@ object ChangeTogglePatch : BaseBytecodePatch(
val stringReference = stableVolumeMethod.getInstruction<ReferenceInstruction>(stringReferenceIndex).reference val stringReference = stableVolumeMethod.getInstruction<ReferenceInstruction>(stringReferenceIndex).reference
CinematicLightingFingerprint.result?.let { CinematicLightingFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val stringIndex = getStringInstructionIndex("menu_item_cinematic_lighting") val stringIndex = getStringInstructionIndex("menu_item_cinematic_lighting")
@ -163,6 +158,6 @@ object ChangeTogglePatch : BaseBytecodePatch(
""", ExternalLabel("ignore", getInstruction(insertIndex)) """, ExternalLabel("ignore", getInstruction(insertIndex))
) )
} }
} ?: throw CinematicLightingFingerprint.exception }
} }
} }

View File

@ -11,10 +11,10 @@ import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.AutoNavPreviewStub import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.AutoNavPreviewStub
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.AutoNavToggle import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.AutoNavToggle
import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getStringInstructionIndex import app.revanced.util.getStringInstructionIndex
import app.revanced.util.getWideLiteralInstructionIndex import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Suppress("unused") @Suppress("unused")
@ -29,7 +29,7 @@ object AutoplayPreviewPatch : BaseBytecodePatch(
fingerprints = setOf(LayoutConstructorFingerprint) fingerprints = setOf(LayoutConstructorFingerprint)
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
LayoutConstructorFingerprint.result?.let { LayoutConstructorFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val dummyRegister = val dummyRegister =
getInstruction<OneRegisterInstruction>(getStringInstructionIndex("1.0x")).registerA getInstruction<OneRegisterInstruction>(getStringInstructionIndex("1.0x")).registerA
@ -44,7 +44,7 @@ object AutoplayPreviewPatch : BaseBytecodePatch(
""", ExternalLabel("hidden", getInstruction(jumpIndex)) """, ExternalLabel("hidden", getInstruction(jumpIndex))
) )
} }
} ?: throw LayoutConstructorFingerprint.exception }
/** /**
* Add settings * Add settings

View File

@ -8,9 +8,9 @@ import app.revanced.patches.youtube.utils.integrations.Constants.COMPATIBLE_PACK
import app.revanced.patches.youtube.utils.integrations.Constants.FULLSCREEN_CLASS_DESCRIPTOR import app.revanced.patches.youtube.utils.integrations.Constants.FULLSCREEN_CLASS_DESCRIPTOR
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getWalkerMethod import app.revanced.util.getWalkerMethod
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Suppress("unused") @Suppress("unused")
@ -26,7 +26,7 @@ object CompactControlsOverlayPatch : BaseBytecodePatch(
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
YouTubeControlsOverlayFingerprint.result?.let { YouTubeControlsOverlayFingerprint.resultOrThrow().let {
val walkerMethod = it.getWalkerMethod(context, it.scanResult.patternScanResult!!.startIndex) val walkerMethod = it.getWalkerMethod(context, it.scanResult.patternScanResult!!.startIndex)
walkerMethod.apply { walkerMethod.apply {
val insertIndex = implementation!!.instructions.size - 1 val insertIndex = implementation!!.instructions.size - 1
@ -40,7 +40,7 @@ object CompactControlsOverlayPatch : BaseBytecodePatch(
""" """
) )
} }
} ?: throw YouTubeControlsOverlayFingerprint.exception }
/** /**
* Add settings * Add settings

View File

@ -10,8 +10,8 @@ import app.revanced.patches.youtube.utils.integrations.Constants.COMPATIBLE_PACK
import app.revanced.patches.youtube.utils.integrations.Constants.FULLSCREEN_CLASS_DESCRIPTOR import app.revanced.patches.youtube.utils.integrations.Constants.FULLSCREEN_CLASS_DESCRIPTOR
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
@Suppress("unused") @Suppress("unused")
object EndScreenOverlayPatch : BaseBytecodePatch( object EndScreenOverlayPatch : BaseBytecodePatch(
@ -25,7 +25,7 @@ object EndScreenOverlayPatch : BaseBytecodePatch(
fingerprints = setOf(EndScreenResultsParentFingerprint) fingerprints = setOf(EndScreenResultsParentFingerprint)
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
EndScreenResultsParentFingerprint.result?.let { EndScreenResultsParentFingerprint.resultOrThrow().let {
it.mutableClass.methods.find { method -> method.parameters == listOf("I", "Z", "I") } it.mutableClass.methods.find { method -> method.parameters == listOf("I", "Z", "I") }
?.apply { ?.apply {
addInstructionsWithLabels( addInstructionsWithLabels(
@ -37,7 +37,7 @@ object EndScreenOverlayPatch : BaseBytecodePatch(
""", ExternalLabel("show", getInstruction(0)) """, ExternalLabel("show", getInstruction(0))
) )
} ?: throw PatchException("Could not find targetMethod") } ?: throw PatchException("Could not find targetMethod")
} ?: throw EndScreenResultsParentFingerprint.exception }
/** /**
* Add settings * Add settings

View File

@ -10,10 +10,10 @@ import app.revanced.patches.youtube.fullscreen.forcefullscreen.fingerprints.Vide
import app.revanced.patches.youtube.utils.integrations.Constants.COMPATIBLE_PACKAGE import app.revanced.patches.youtube.utils.integrations.Constants.COMPATIBLE_PACKAGE
import app.revanced.patches.youtube.utils.integrations.Constants.FULLSCREEN_CLASS_DESCRIPTOR import app.revanced.patches.youtube.utils.integrations.Constants.FULLSCREEN_CLASS_DESCRIPTOR
import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getStringInstructionIndex import app.revanced.util.getStringInstructionIndex
import app.revanced.util.getTargetIndex import app.revanced.util.getTargetIndex
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -35,7 +35,7 @@ object ForceFullscreenPatch : BaseBytecodePatch(
/** /**
* Process that hooks Activity for using {Activity.setRequestedOrientation}. * Process that hooks Activity for using {Activity.setRequestedOrientation}.
*/ */
ClientSettingEndpointFingerprint.result?.let { ClientSettingEndpointFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val getActivityIndex = getStringInstructionIndex("watch") + 2 val getActivityIndex = getStringInstructionIndex("watch") + 2
val getActivityReference = val getActivityReference =
@ -66,13 +66,13 @@ object ForceFullscreenPatch : BaseBytecodePatch(
""" """
) )
} }
} ?: throw ClientSettingEndpointFingerprint.exception }
/** /**
* Don't rotate the screen in vertical video. * Don't rotate the screen in vertical video.
* Add an instruction to check the vertical video. * Add an instruction to check the vertical video.
*/ */
VideoPortraitParentFingerprint.result?.let { VideoPortraitParentFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val stringIndex = val stringIndex =
getStringInstructionIndex("Acquiring NetLatencyActionLogger failed. taskId=") getStringInstructionIndex("Acquiring NetLatencyActionLogger failed. taskId=")
@ -90,7 +90,7 @@ object ForceFullscreenPatch : BaseBytecodePatch(
) )
} ?: throw PatchException("Could not find targetMethod") } ?: throw PatchException("Could not find targetMethod")
} }
} ?: throw VideoPortraitParentFingerprint.exception }
/** /**
* Add settings * Add settings

View File

@ -12,11 +12,11 @@ import app.revanced.patches.youtube.utils.integrations.Constants.FULLSCREEN_CLAS
import app.revanced.patches.youtube.utils.quickactions.QuickActionsHookPatch import app.revanced.patches.youtube.utils.quickactions.QuickActionsHookPatch
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.FullScreenEngagementPanel import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.FullScreenEngagementPanel
import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getTargetIndex import app.revanced.util.getTargetIndex
import app.revanced.util.getTargetIndexWithMethodReferenceName import app.revanced.util.getTargetIndexWithMethodReferenceName
import app.revanced.util.getWideLiteralInstructionIndex import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -36,7 +36,7 @@ object FullscreenPanelsPatch : BaseBytecodePatch(
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
FullscreenEngagementPanelFingerprint.result?.let { FullscreenEngagementPanelFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val literalIndex = getWideLiteralInstructionIndex(FullScreenEngagementPanel) val literalIndex = getWideLiteralInstructionIndex(FullScreenEngagementPanel)
val targetIndex = getTargetIndex(literalIndex, Opcode.CHECK_CAST) val targetIndex = getTargetIndex(literalIndex, Opcode.CHECK_CAST)
@ -47,9 +47,9 @@ object FullscreenPanelsPatch : BaseBytecodePatch(
"invoke-static {v$targetRegister}, $FULLSCREEN_CLASS_DESCRIPTOR->hideFullscreenPanels(Landroidx/coordinatorlayout/widget/CoordinatorLayout;)V" "invoke-static {v$targetRegister}, $FULLSCREEN_CLASS_DESCRIPTOR->hideFullscreenPanels(Landroidx/coordinatorlayout/widget/CoordinatorLayout;)V"
) )
} }
} ?: throw FullscreenEngagementPanelFingerprint.exception }
LayoutConstructorFingerprint.result?.let { LayoutConstructorFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val dummyIndex = getWideLiteralInstructionIndex(159962) val dummyIndex = getWideLiteralInstructionIndex(159962)
val dummyRegister = getInstruction<OneRegisterInstruction>(dummyIndex).registerA val dummyRegister = getInstruction<OneRegisterInstruction>(dummyIndex).registerA
@ -63,7 +63,7 @@ object FullscreenPanelsPatch : BaseBytecodePatch(
""", ExternalLabel("hidden", getInstruction(addViewIndex + 1)) """, ExternalLabel("hidden", getInstruction(addViewIndex + 1))
) )
} }
} ?: throw LayoutConstructorFingerprint.exception }
/** /**
* Add settings * Add settings

View File

@ -12,10 +12,10 @@ import app.revanced.patches.youtube.fullscreen.landscapemode.fingerprints.Orient
import app.revanced.patches.youtube.utils.integrations.Constants.COMPATIBLE_PACKAGE import app.revanced.patches.youtube.utils.integrations.Constants.COMPATIBLE_PACKAGE
import app.revanced.patches.youtube.utils.integrations.Constants.FULLSCREEN_CLASS_DESCRIPTOR import app.revanced.patches.youtube.utils.integrations.Constants.FULLSCREEN_CLASS_DESCRIPTOR
import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getStringInstructionIndex import app.revanced.util.getStringInstructionIndex
import app.revanced.util.getTargetIndex import app.revanced.util.getTargetIndex
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -36,28 +36,28 @@ object LandScapeModePatch : BaseBytecodePatch(
/** /**
* Disable landscape mode * Disable landscape mode
*/ */
OrientationParentFingerprint.result?.classDef?.let { classDef -> OrientationParentFingerprint.resultOrThrow().classDef.let { classDef ->
arrayOf( arrayOf(
OrientationPrimaryFingerprint, OrientationPrimaryFingerprint,
OrientationSecondaryFingerprint OrientationSecondaryFingerprint
).forEach { fingerprint -> ).forEach { fingerprint ->
fingerprint.resolve(context, classDef) fingerprint.resolve(context, classDef)
fingerprint.result?.let { fingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val index = it.scanResult.patternScanResult!!.endIndex val index = it.scanResult.patternScanResult!!.endIndex
val register = getInstruction<OneRegisterInstruction>(index).registerA val register = getInstruction<OneRegisterInstruction>(index).registerA
addInstructions( addInstructions(
index + 1, """ index + 1, """
invoke-static {v$register}, $FULLSCREEN_CLASS_DESCRIPTOR->disableLandScapeMode(Z)Z invoke-static {v$register}, $FULLSCREEN_CLASS_DESCRIPTOR->disableLandScapeMode(Z)Z
move-result v$register move-result v$register
""" """
) )
} }
} ?: throw fingerprint.exception }
} }
} ?: throw OrientationParentFingerprint.exception }
/** /**
* Keep landscape mode * Keep landscape mode
@ -75,7 +75,7 @@ object LandScapeModePatch : BaseBytecodePatch(
) )
} }
BroadcastReceiverFingerprint.result?.let { result -> BroadcastReceiverFingerprint.resultOrThrow().let { result ->
result.mutableMethod.apply { result.mutableMethod.apply {
val stringIndex = getStringInstructionIndex("android.intent.action.SCREEN_ON") val stringIndex = getStringInstructionIndex("android.intent.action.SCREEN_ON")
val insertIndex = getTargetIndex(stringIndex, Opcode.IF_EQZ) + 1 val insertIndex = getTargetIndex(stringIndex, Opcode.IF_EQZ) + 1
@ -85,7 +85,7 @@ object LandScapeModePatch : BaseBytecodePatch(
"invoke-static {}, $FULLSCREEN_CLASS_DESCRIPTOR->setScreenStatus()V" "invoke-static {}, $FULLSCREEN_CLASS_DESCRIPTOR->setScreenStatus()V"
) )
} }
} ?: throw BroadcastReceiverFingerprint.exception }
SettingsPatch.addPreference( SettingsPatch.addPreference(
arrayOf( arrayOf(

View File

@ -14,8 +14,8 @@ import app.revanced.patches.youtube.utils.integrations.Constants.COMPATIBLE_PACK
import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL_CLASS_DESCRIPTOR import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL_CLASS_DESCRIPTOR
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
@ -36,10 +36,10 @@ object AccountMenuPatch : BaseBytecodePatch(
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
AccountListParentFingerprint.result?.let { parentResult -> AccountListParentFingerprint.resultOrThrow().let { parentResult ->
AccountListFingerprint.resolve(context, parentResult.classDef) AccountListFingerprint.resolve(context, parentResult.classDef)
AccountListFingerprint.result?.let { AccountListFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.startIndex + 3 val targetIndex = it.scanResult.patternScanResult!!.startIndex + 3
val targetInstruction = getInstruction<FiveRegisterInstruction>(targetIndex) val targetInstruction = getInstruction<FiveRegisterInstruction>(targetIndex)
@ -50,14 +50,14 @@ object AccountMenuPatch : BaseBytecodePatch(
"$GENERAL_CLASS_DESCRIPTOR->hideAccountList(Landroid/view/View;Ljava/lang/CharSequence;)V" "$GENERAL_CLASS_DESCRIPTOR->hideAccountList(Landroid/view/View;Ljava/lang/CharSequence;)V"
) )
} }
} ?: throw AccountListFingerprint.exception }
} ?: throw AccountListParentFingerprint.exception }
AccountMenuParentFingerprint.result?.let { parentResult -> AccountMenuParentFingerprint.resultOrThrow().let { parentResult ->
AccountMenuFingerprint.resolve(context, parentResult.classDef) AccountMenuFingerprint.resolve(context, parentResult.classDef)
SetViewGroupMarginFingerprint.resolve(context, parentResult.classDef) SetViewGroupMarginFingerprint.resolve(context, parentResult.classDef)
AccountMenuFingerprint.result?.let { AccountMenuFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.startIndex + 2 val targetIndex = it.scanResult.patternScanResult!!.startIndex + 2
val targetInstruction = getInstruction<FiveRegisterInstruction>(targetIndex) val targetInstruction = getInstruction<FiveRegisterInstruction>(targetIndex)
@ -68,23 +68,23 @@ object AccountMenuPatch : BaseBytecodePatch(
"$GENERAL_CLASS_DESCRIPTOR->hideAccountMenu(Landroid/view/View;Ljava/lang/CharSequence;)V" "$GENERAL_CLASS_DESCRIPTOR->hideAccountMenu(Landroid/view/View;Ljava/lang/CharSequence;)V"
) )
} }
} ?: throw AccountMenuFingerprint.exception }
SetViewGroupMarginFingerprint.result?.let { SetViewGroupMarginFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val setViewGroupMarginIndex = it.scanResult.patternScanResult!!.startIndex val setViewGroupMarginIndex = it.scanResult.patternScanResult!!.startIndex
val setViewGroupMarginReference = val setViewGroupMarginReference =
getInstruction<ReferenceInstruction>(setViewGroupMarginIndex).reference getInstruction<ReferenceInstruction>(setViewGroupMarginIndex).reference
AccountMenuPatchFingerprint.result?.mutableMethod?.addInstructions( AccountMenuPatchFingerprint.resultOrThrow().mutableMethod.addInstructions(
0, """ 0, """
const/4 v0, 0x0 const/4 v0, 0x0
invoke-static {p0, v0, v0}, $setViewGroupMarginReference invoke-static {p0, v0, v0}, $setViewGroupMarginReference
""" """
) ?: throw AccountMenuPatchFingerprint.exception )
} }
} ?: throw SetViewGroupMarginFingerprint.exception }
} ?: throw AccountMenuParentFingerprint.exception }
/** /**
* Add settings * Add settings

View File

@ -8,8 +8,8 @@ import app.revanced.patches.youtube.general.autopopuppanels.fingerprints.Engagem
import app.revanced.patches.youtube.utils.integrations.Constants.COMPATIBLE_PACKAGE import app.revanced.patches.youtube.utils.integrations.Constants.COMPATIBLE_PACKAGE
import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL_CLASS_DESCRIPTOR import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL_CLASS_DESCRIPTOR
import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
@Suppress("unused") @Suppress("unused")
object PlayerPopupPanelsPatch : BaseBytecodePatch( object PlayerPopupPanelsPatch : BaseBytecodePatch(
@ -21,7 +21,7 @@ object PlayerPopupPanelsPatch : BaseBytecodePatch(
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
EngagementPanelControllerFingerprint.result?.let { EngagementPanelControllerFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
addInstructionsWithLabels( addInstructionsWithLabels(
0, """ 0, """
@ -35,7 +35,7 @@ object PlayerPopupPanelsPatch : BaseBytecodePatch(
""", ExternalLabel("shown", getInstruction(0)) """, ExternalLabel("shown", getInstruction(0))
) )
} }
} ?: throw EngagementPanelControllerFingerprint.exception }
/** /**
* Add settings * Add settings

View File

@ -6,8 +6,8 @@ import app.revanced.patches.youtube.general.castbutton.fingerprints.CastButtonFi
import app.revanced.patches.youtube.utils.integrations.Constants.COMPATIBLE_PACKAGE import app.revanced.patches.youtube.utils.integrations.Constants.COMPATIBLE_PACKAGE
import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL_CLASS_DESCRIPTOR import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL_CLASS_DESCRIPTOR
import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
@Suppress("unused") @Suppress("unused")
object CastButtonPatch : BaseBytecodePatch( object CastButtonPatch : BaseBytecodePatch(
@ -18,7 +18,7 @@ object CastButtonPatch : BaseBytecodePatch(
fingerprints = setOf(CastButtonFingerprint) fingerprints = setOf(CastButtonFingerprint)
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
CastButtonFingerprint.result?.let { CastButtonFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
addInstructions( addInstructions(
0, """ 0, """
@ -27,7 +27,7 @@ object CastButtonPatch : BaseBytecodePatch(
""" """
) )
} }
} ?: throw CastButtonFingerprint.exception }
/** /**
* Add settings * Add settings

View File

@ -11,8 +11,8 @@ import app.revanced.patches.youtube.utils.integrations.Constants.COMPATIBLE_PACK
import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL_CLASS_DESCRIPTOR import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL_CLASS_DESCRIPTOR
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
@ -71,7 +71,7 @@ object CategoryBarPatch : BaseBytecodePatch(
hookRegisterOffset: Int = 0, hookRegisterOffset: Int = 0,
instructions: (Int) -> String instructions: (Int) -> String
) = ) =
result?.let { resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val endIndex = it.scanResult.patternScanResult!!.endIndex val endIndex = it.scanResult.patternScanResult!!.endIndex
@ -81,5 +81,5 @@ object CategoryBarPatch : BaseBytecodePatch(
addInstructions(insertIndex, instructions(register)) addInstructions(insertIndex, instructions(register))
} }
} ?: throw exception }
} }

View File

@ -10,8 +10,8 @@ import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH
import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL_CLASS_DESCRIPTOR import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL_CLASS_DESCRIPTOR
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Suppress("unused") @Suppress("unused")
@ -32,7 +32,7 @@ object ChannelListSubMenuPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR) LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)
ChannelListSubMenuFingerprint.result?.let { ChannelListSubMenuFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val endIndex = it.scanResult.patternScanResult!!.endIndex val endIndex = it.scanResult.patternScanResult!!.endIndex
val register = getInstruction<OneRegisterInstruction>(endIndex).registerA val register = getInstruction<OneRegisterInstruction>(endIndex).registerA
@ -42,7 +42,7 @@ object ChannelListSubMenuPatch : BaseBytecodePatch(
"invoke-static {v$register}, $GENERAL_CLASS_DESCRIPTOR->hideChannelListSubMenu(Landroid/view/View;)V" "invoke-static {v$register}, $GENERAL_CLASS_DESCRIPTOR->hideChannelListSubMenu(Landroid/view/View;)V"
) )
} }
} ?: throw ChannelListSubMenuFingerprint.exception }
/** /**
* Add settings * Add settings

View File

@ -10,9 +10,9 @@ import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.TabsBarTextTabView import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.TabsBarTextTabView
import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getWideLiteralInstructionIndex import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Suppress("unused") @Suppress("unused")
@ -32,7 +32,7 @@ object ChannelProfileComponentsPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
DefaultsTabsBarFingerprint.result?.let { DefaultsTabsBarFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val viewIndex = getWideLiteralInstructionIndex(TabsBarTextTabView) + 2 val viewIndex = getWideLiteralInstructionIndex(TabsBarTextTabView) + 2
val viewRegister = getInstruction<OneRegisterInstruction>(viewIndex).registerA val viewRegister = getInstruction<OneRegisterInstruction>(viewIndex).registerA
@ -42,7 +42,7 @@ object ChannelProfileComponentsPatch : BaseBytecodePatch(
"sput-object v$viewRegister, $FILTER_CLASS_DESCRIPTOR->channelTabView:Landroid/view/View;" "sput-object v$viewRegister, $FILTER_CLASS_DESCRIPTOR->channelTabView:Landroid/view/View;"
) )
} }
} ?: throw DefaultsTabsBarFingerprint.exception }
LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR) LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)

View File

@ -8,8 +8,8 @@ import app.revanced.patches.youtube.utils.integrations.Constants.COMPATIBLE_PACK
import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL_CLASS_DESCRIPTOR import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL_CLASS_DESCRIPTOR
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
@Suppress("unused") @Suppress("unused")
@ -25,7 +25,7 @@ object CrowdfundingBoxPatch : BaseBytecodePatch(
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
CrowdfundingBoxFingerprint.result?.let { CrowdfundingBoxFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.endIndex val insertIndex = it.scanResult.patternScanResult!!.endIndex
val register = getInstruction<TwoRegisterInstruction>(insertIndex).registerA val register = getInstruction<TwoRegisterInstruction>(insertIndex).registerA
@ -35,7 +35,7 @@ object CrowdfundingBoxPatch : BaseBytecodePatch(
"invoke-static {v$register}, $GENERAL_CLASS_DESCRIPTOR->hideCrowdfundingBox(Landroid/view/View;)V" "invoke-static {v$register}, $GENERAL_CLASS_DESCRIPTOR->hideCrowdfundingBox(Landroid/view/View;)V"
) )
} }
} ?: throw CrowdfundingBoxFingerprint.exception }
/** /**
* Add settings * Add settings

View File

@ -10,9 +10,9 @@ import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH
import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL_CLASS_DESCRIPTOR import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL_CLASS_DESCRIPTOR
import app.revanced.patches.youtube.utils.recyclerview.BottomSheetRecyclerViewPatch import app.revanced.patches.youtube.utils.recyclerview.BottomSheetRecyclerViewPatch
import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getTargetIndexWithMethodReferenceName import app.revanced.util.getTargetIndexWithMethodReferenceName
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
@Suppress("unused") @Suppress("unused")
@ -33,7 +33,7 @@ object DescriptionComponentsPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
if (SettingsPatch.upward1902) { if (SettingsPatch.upward1902) {
TextViewComponentFingerprint.result?.let { TextViewComponentFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val insertIndex = getTargetIndexWithMethodReferenceName("setTextIsSelectable") val insertIndex = getTargetIndexWithMethodReferenceName("setTextIsSelectable")
val insertInstruction = getInstruction<FiveRegisterInstruction>(insertIndex) val insertInstruction = getInstruction<FiveRegisterInstruction>(insertIndex)
@ -44,7 +44,7 @@ object DescriptionComponentsPatch : BaseBytecodePatch(
"$GENERAL_CLASS_DESCRIPTOR->disableDescriptionInteraction(Landroid/widget/TextView;Z)V" "$GENERAL_CLASS_DESCRIPTOR->disableDescriptionInteraction(Landroid/widget/TextView;Z)V"
) )
} }
} ?: throw TextViewComponentFingerprint.exception }
BottomSheetRecyclerViewPatch.injectCall("$GENERAL_CLASS_DESCRIPTOR->onDescriptionPanelCreate(Landroid/support/v7/widget/RecyclerView;)V") BottomSheetRecyclerViewPatch.injectCall("$GENERAL_CLASS_DESCRIPTOR->onDescriptionPanelCreate(Landroid/support/v7/widget/RecyclerView;)V")

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