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.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getTargetIndexWithMethodReferenceName
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
@Suppress("unused")
@ -27,7 +27,7 @@ object MenuComponentPatch : BaseBytecodePatch(
) {
override fun execute(context: BytecodeContext) {
MenuEntryFingerprint.result?.let {
MenuEntryFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val textIndex = getTargetIndexWithMethodReferenceName("setText")
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"
)
}
} ?: throw MenuEntryFingerprint.exception
}
SettingsPatch.addMusicPreference(
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.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getTargetIndexWithMethodReferenceName
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.OneRegisterInstruction
@ -36,7 +36,7 @@ object HandlePatch : BaseBytecodePatch(
/**
* Hide handle in account menu
*/
AccountSwitcherAccessibilityLabelFingerprint.result?.let { result ->
AccountSwitcherAccessibilityLabelFingerprint.resultOrThrow().let { result ->
result.mutableMethod.apply {
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"
)
}
} ?: throw AccountSwitcherAccessibilityLabelFingerprint.exception
}
/**
* Hide handle in account switcher
*/
NamesInactiveAccountThumbnailSizeFingerprint.result?.let {
NamesInactiveAccountThumbnailSizeFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.startIndex
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
@ -65,7 +65,7 @@ object HandlePatch : BaseBytecodePatch(
"""
)
}
} ?: throw NamesInactiveAccountThumbnailSizeFingerprint.exception
}
SettingsPatch.addMusicPreference(
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.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getTargetIndexWithReference
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
@Suppress("unused")
@ -28,7 +28,7 @@ object TermsContainerPatch : BaseBytecodePatch(
) {
override fun execute(context: BytecodeContext) {
TermsOfServiceFingerprint.result?.let {
TermsOfServiceFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val insertIndex = getTargetIndexWithReference("/PrivacyTosFooter;->setVisibility(I)V")
val visibilityRegister =
@ -45,7 +45,7 @@ object TermsContainerPatch : BaseBytecodePatch(
"""
)
}
} ?: throw TermsOfServiceFingerprint.exception
}
SettingsPatch.addMusicPreference(
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.SettingsPatch
import app.revanced.patches.music.video.information.VideoInformationPatch
import app.revanced.util.exception
import app.revanced.util.getTargetIndexWithMethodReferenceName
import app.revanced.util.getTargetIndexWithReference
import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.indexOfFirstInstruction
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -46,7 +46,7 @@ object ActionBarComponentPatch : BaseBytecodePatch(
)
) {
override fun execute(context: BytecodeContext) {
ActionBarComponentFingerprint.result?.let {
ActionBarComponentFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
// hook download button
@ -118,9 +118,9 @@ object ActionBarComponentPatch : BaseBytecodePatch(
"invoke-static {v$buttonTypeDownloadRegister}, $ACTIONBAR_CLASS_DESCRIPTOR->setButtonTypeDownload(I)V"
)
}
} ?: throw ActionBarComponentFingerprint.exception
}
LikeDislikeContainerFingerprint.result?.let { parentResult ->
LikeDislikeContainerFingerprint.resultOrThrow().let { parentResult ->
// Resolves fingerprints
LikeDislikeContainerVisibilityFingerprint.resolve(context, parentResult.classDef)
@ -151,7 +151,7 @@ object ActionBarComponentPatch : BaseBytecodePatch(
"invoke-static {v$insertRegister}, $ACTIONBAR_CLASS_DESCRIPTOR->hideLikeDislikeButton(Landroid/view/View;)V"
)
}
} ?: throw LikeDislikeContainerFingerprint.exception
}
SettingsPatch.addMusicPreference(
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.SettingsPatch
import app.revanced.patches.shared.litho.LithoFilterPatch
import app.revanced.util.exception
import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Suppress("unused")
@ -62,7 +62,7 @@ object GeneralAdsPatch : BaseBytecodePatch(
* Hides fullscreen ads
* Non-litho view, used in some old clients.
*/
InterstitialsContainerFingerprint.result?.let {
InterstitialsContainerFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val targetIndex = getWideLiteralInstructionIndex(InterstitialsContainer) + 2
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"
)
}
} ?: throw InterstitialsContainerFingerprint.exception
}
/**
* Hides fullscreen ads
* Litho view, used in 'ShowDialogCommandOuterClass' in innertube
*/
ShowDialogCommandFingerprint.result?.let {
ShowDialogCommandFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
// In this method, custom dialog is created and shown.
// 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
*/
FloatingLayoutFingerprint.result?.let {
FloatingLayoutFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val targetIndex = getWideLiteralInstructionIndex(FloatingLayout) + 2
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"
)
}
} ?: throw FloatingLayoutFingerprint.exception
}
/**
* Hides premium renewal banner
*/
NotifierShelfFingerprint.result?.let {
NotifierShelfFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val linearLayoutIndex = getWideLiteralInstructionIndex(ButtonContainer) + 3
val linearLayoutRegister =
@ -156,7 +156,7 @@ object GeneralAdsPatch : BaseBytecodePatch(
"invoke-static {v$linearLayoutRegister}, $PREMIUM_PROMOTION_BANNER_CLASS_DESCRIPTOR->hidePremiumRenewal(Landroid/widget/LinearLayout;)V"
)
}
} ?: throw NotifierShelfFingerprint.exception
}
SettingsPatch.addMusicPreference(
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.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getWalkerMethod
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
@Suppress("unused")
object CompactDialogPatch : BaseBytecodePatch(
@ -24,7 +24,7 @@ object CompactDialogPatch : BaseBytecodePatch(
fingerprints = setOf(DialogSolidFingerprint)
) {
override fun execute(context: BytecodeContext) {
DialogSolidFingerprint.result?.let {
DialogSolidFingerprint.resultOrThrow().let {
val walkerMethod = it.getWalkerMethod(context, it.scanResult.patternScanResult!!.endIndex)
walkerMethod.addInstructions(
2, """
@ -32,7 +32,7 @@ object CompactDialogPatch : BaseBytecodePatch(
move-result p0
"""
)
} ?: throw DialogSolidFingerprint.exception
}
SettingsPatch.addMusicPreference(
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.SettingsPatch
import app.revanced.patches.shared.litho.LithoFilterPatch
import app.revanced.util.exception
import app.revanced.util.getTargetIndex
import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -43,7 +43,7 @@ object FlyoutPanelPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) {
FlyoutPanelMenuItemPatch.hideComponents()
EndButtonsContainerFingerprint.result?.let {
EndButtonsContainerFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val startIndex = getWideLiteralInstructionIndex(EndButtonsContainer)
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"
)
}
} ?: throw EndButtonsContainerFingerprint.exception
}
/**
* 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.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getTargetIndexWithMethodReferenceName
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
@Suppress("unused")
@ -33,7 +33,7 @@ object ReplaceReportPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) {
FlyoutPanelMenuItemPatch.replaceComponents()
TouchOutsideFingerprint.result?.let {
TouchOutsideFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val setOnClickListenerIndex = getTargetIndexWithMethodReferenceName("setOnClickListener")
val setOnClickListenerRegister = getInstruction<FiveRegisterInstruction>(setOnClickListenerIndex).registerC
@ -43,7 +43,7 @@ object ReplaceReportPatch : BaseBytecodePatch(
"sput-object v$setOnClickListenerRegister, $FLYOUT_CLASS_DESCRIPTOR->touchOutSideView:Landroid/view/View;"
)
}
} ?: throw TouchOutsideFingerprint.exception
}
SettingsPatch.addMusicPreference(
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.patches.music.flyoutpanel.shared.fingerprints.MenuItemFingerprint
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.indexOfFirstInstruction
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
@ -28,7 +28,7 @@ object FlyoutPanelMenuItemPatch : BytecodePatch(
private var instructionAdded = false
override fun execute(context: BytecodeContext) {
MenuItemFingerprint.result?.let {
MenuItemFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val freeIndex = getTargetIndex(Opcode.OR_INT_LIT16)
val textViewIndex = it.scanResult.patternScanResult!!.startIndex
@ -43,7 +43,7 @@ object FlyoutPanelMenuItemPatch : BytecodePatch(
menuItemMethod = this
}
} ?: throw MenuItemFingerprint.exception
}
}
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.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Suppress("unused")
@ -37,7 +37,7 @@ object CastButtonPatch : BaseBytecodePatch(
/**
* Hide cast button
*/
MediaRouteButtonFingerprint.result?.let {
MediaRouteButtonFingerprint.resultOrThrow().let {
val setVisibilityMethod =
it.mutableClass.methods.find { method -> method.name == "setVisibility" }
@ -49,12 +49,12 @@ object CastButtonPatch : BaseBytecodePatch(
"""
)
} ?: throw PatchException("Failed to find setVisibility method")
} ?: throw MediaRouteButtonFingerprint.exception
}
/**
* Hide floating cast banner
*/
PlayerOverlayChipFingerprint.result?.let {
PlayerOverlayChipFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val targetIndex = getWideLiteralInstructionIndex(PlayerOverlayChip) + 2
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"
)
}
} ?: throw PlayerOverlayChipFingerprint.exception
}
SettingsPatch.addMusicPreference(
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.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Suppress("unused")
@ -25,7 +25,7 @@ object CategoryBarPatch : BaseBytecodePatch(
fingerprints = setOf(ChipCloudFingerprint)
) {
override fun execute(context: BytecodeContext) {
ChipCloudFingerprint.result?.let {
ChipCloudFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.endIndex
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"
)
}
} ?: throw ChipCloudFingerprint.exception
}
SettingsPatch.addMusicPreference(
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.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
@Suppress("unused")
object FloatingButtonPatch : BaseBytecodePatch(
@ -27,13 +27,13 @@ object FloatingButtonPatch : BaseBytecodePatch(
) {
override fun execute(context: BytecodeContext) {
FloatingButtonParentFingerprint.result?.let { parentResult ->
FloatingButtonParentFingerprint.resultOrThrow().let { parentResult ->
FloatingButtonFingerprint.also {
it.resolve(
context,
parentResult.classDef
)
}.result?.let {
}.resultOrThrow().let {
it.mutableMethod.apply {
addInstructionsWithLabels(
1, """
@ -44,8 +44,8 @@ object FloatingButtonPatch : BaseBytecodePatch(
""", ExternalLabel("show", getInstruction(1))
)
}
} ?: throw FloatingButtonFingerprint.exception
} ?: throw FloatingButtonParentFingerprint.exception
}
}
SettingsPatch.addMusicPreference(
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.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
@Suppress("unused")
@ -34,7 +34,7 @@ object HistoryButtonPatch : BaseBytecodePatch(
HistoryMenuItemFingerprint,
HistoryMenuItemOfflineTabFingerprint
).forEach { fingerprint ->
fingerprint.result?.let {
fingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.startIndex
val insertRegister = getInstruction<FiveRegisterInstruction>(insertIndex).registerD
@ -46,7 +46,7 @@ object HistoryButtonPatch : BaseBytecodePatch(
"""
)
}
} ?: throw fingerprint.exception
}
}
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.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Suppress("unused")
@ -25,7 +25,7 @@ object LandScapeModePatch : BaseBytecodePatch(
fingerprints = setOf(TabletIdentifierFingerprint)
) {
override fun execute(context: BytecodeContext) {
TabletIdentifierFingerprint.result?.let {
TabletIdentifierFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.endIndex
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
@ -37,7 +37,7 @@ object LandScapeModePatch : BaseBytecodePatch(
"""
)
}
} ?: throw TabletIdentifierFingerprint.exception
}
SettingsPatch.addMusicPreference(
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.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getStringInstructionIndex
import app.revanced.util.getTargetIndexReversed
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
@ -25,7 +25,7 @@ object OldStyleLibraryShelfPatch : BaseBytecodePatch(
) {
override fun execute(context: BytecodeContext) {
BrowseIdFingerprint.result?.let {
BrowseIdFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val stringIndex = getStringInstructionIndex("FEmusic_offline")
val targetIndex = getTargetIndexReversed(stringIndex, Opcode.IGET_OBJECT)
@ -38,7 +38,7 @@ object OldStyleLibraryShelfPatch : BaseBytecodePatch(
"""
)
}
} ?: throw BrowseIdFingerprint.exception
}
SettingsPatch.addMusicPreference(
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.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getStringInstructionIndex
import app.revanced.util.getTargetIndexReversed
import app.revanced.util.getTargetIndexWithReference
import app.revanced.util.getWalkerMethod
import app.revanced.util.indexOfFirstInstruction
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
@ -39,7 +39,7 @@ object DislikeRedirectionPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) {
PendingIntentReceiverFingerprint.result?.let {
PendingIntentReceiverFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val startIndex = getStringInstructionIndex("YTM Dislike")
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 {
val onClickIndex = getTargetIndexWithReference(onClickReference.toString())
injectCall(onClickIndex)
}
} ?: throw DislikeButtonOnClickListenerFingerprint.exception
}
SettingsPatch.addMusicPreference(
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.contexts
import app.revanced.util.copyXmlNode
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Suppress("unused")
@ -25,7 +25,7 @@ object ChangeStartPagePatch : BaseBytecodePatch(
) {
override fun execute(context: BytecodeContext) {
ColdStartUpFingerprint.result?.let {
ColdStartUpFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.endIndex
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
@ -39,7 +39,7 @@ object ChangeStartPagePatch : BaseBytecodePatch(
)
removeInstruction(targetIndex)
}
} ?: throw ColdStartUpFingerprint.exception
}
/**
* 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.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
@Suppress("unused")
object TapToUpdateButtonPatch : BaseBytecodePatch(
@ -22,7 +22,7 @@ object TapToUpdateButtonPatch : BaseBytecodePatch(
) {
override fun execute(context: BytecodeContext) {
ContentPillInFingerprint.result?.let {
ContentPillInFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
addInstructionsWithLabels(
0,
@ -34,7 +34,7 @@ object TapToUpdateButtonPatch : BaseBytecodePatch(
""", ExternalLabel("show", getInstruction(0))
)
}
} ?: throw ContentPillInFingerprint.exception
}
SettingsPatch.addMusicPreference(
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.utils.integrations.Constants.COMPATIBLE_PACKAGE
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
@Suppress("unused")
object TooltipContentViewPatch : BaseBytecodePatch(
@ -18,10 +18,10 @@ object TooltipContentViewPatch : BaseBytecodePatch(
) {
override fun execute(context: BytecodeContext) {
TooltipContentViewFingerprint.result?.mutableMethod?.addInstruction(
TooltipContentViewFingerprint.resultOrThrow().mutableMethod.addInstruction(
0,
"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.IntegrationsPatch
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
@Patch(
@ -24,7 +24,7 @@ object OverlayFilterBytecodePatch : BytecodePatch(
) {
override fun execute(context: BytecodeContext) {
DesignBottomSheetDialogFingerprint.result?.let {
DesignBottomSheetDialogFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.endIndex - 1
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.patches.music.misc.backgroundplay.fingerprints.BackgroundPlaybackFingerprint
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.resultOrThrow
@Suppress("unused")
object BackgroundPlayPatch : BaseBytecodePatch(
@ -16,7 +16,7 @@ object BackgroundPlayPatch : BaseBytecodePatch(
) {
override fun execute(context: BytecodeContext) {
BackgroundPlaybackFingerprint.result?.let {
BackgroundPlaybackFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
addInstructions(
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.",
compatiblePackages = COMPATIBLE_PACKAGE
) {
private const val RESOURCE_FILE_PATH = "res/xml/data_saving_settings.xml"
override fun execute(context: ResourceContext) {
context.xmlEditor[RESOURCE_FILE_PATH].use { editor ->
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.PodCastConfigFingerprint
import app.revanced.patches.music.utils.integrations.Constants.COMPATIBLE_PACKAGE
import app.revanced.util.exception
import app.revanced.util.getStringInstructionIndex
import app.revanced.util.getWalkerMethod
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -33,7 +33,7 @@ object ExclusiveAudioPatch : BaseBytecodePatch(
/**
* Don't play music videos
*/
MusicBrowserServiceFingerprint.result?.let {
MusicBrowserServiceFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val targetIndex =
getStringInstructionIndex("MBS: Return empty root for client: %s, isFullMediaBrowserEnabled: %b, is client browsable: %b, isRedAccount: %b")
@ -56,12 +56,12 @@ object ExclusiveAudioPatch : BaseBytecodePatch(
break
}
}
} ?: throw MusicBrowserServiceFingerprint.exception
}
/**
* Don't play podcast videos
*/
PodCastConfigFingerprint.result?.let {
PodCastConfigFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val insertIndex = implementation!!.instructions.size - 1
val targetRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
@ -71,9 +71,9 @@ object ExclusiveAudioPatch : BaseBytecodePatch(
"const/4 v$targetRegister, 0x1"
)
}
} ?: throw PodCastConfigFingerprint.exception
}
DataSavingSettingsFragmentFingerprint.result?.let {
DataSavingSettingsFragmentFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val insertIndex = getStringInstructionIndex("pref_key_dont_play_nma_video") + 4
val targetRegister = getInstruction<FiveRegisterInstruction>(insertIndex).registerD
@ -83,6 +83,6 @@ object ExclusiveAudioPatch : BaseBytecodePatch(
"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.patches.music.misc.minimizedplayback.fingerprints.MinimizedPlaybackManagerFingerprint
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.resultOrThrow
@Suppress("unused")
object MinimizedPlaybackPatch : BaseBytecodePatch(
@ -16,9 +16,9 @@ object MinimizedPlaybackPatch : BaseBytecodePatch(
) {
override fun execute(context: BytecodeContext) {
MinimizedPlaybackManagerFingerprint.result?.mutableMethod?.addInstruction(
MinimizedPlaybackManagerFingerprint.resultOrThrow().mutableMethod.addInstruction(
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.resourceid.SharedResourceIdPatch
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.PrivacyTosFooter
import app.revanced.util.exception
import app.revanced.util.getTargetIndex
import app.revanced.util.getTargetIndexWithReference
import app.revanced.util.getWalkerMethod
import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
@ -41,7 +41,7 @@ object GetPremiumPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) {
// Hides get premium button at the bottom of the account switching menu
HideGetPremiumFingerprint.result?.let {
HideGetPremiumFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.startIndex
val register = getInstruction<TwoRegisterInstruction>(insertIndex).registerA
@ -51,10 +51,10 @@ object GetPremiumPatch : BaseBytecodePatch(
"const/4 v$register, 0x0"
)
}
} ?: throw HideGetPremiumFingerprint.exception
}
// Hides get premium button at the top of the account switching menu
AccountMenuFooterFingerprint.result?.let {
AccountMenuFooterFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val constIndex = getWideLiteralInstructionIndex(PrivacyTosFooter)
val walkerIndex = getTargetIndex(constIndex + 2, Opcode.INVOKE_VIRTUAL)
@ -73,18 +73,18 @@ object GetPremiumPatch : BaseBytecodePatch(
)
}
}
} ?: throw AccountMenuFooterFingerprint.exception
}
// Hides premium membership menu in settings
MembershipSettingsParentFingerprint.result?.classDef?.let { classDef ->
MembershipSettingsParentFingerprint.resultOrThrow().classDef.let { classDef ->
MembershipSettingsFingerprint.resolve(context, classDef)
MembershipSettingsFingerprint.result?.mutableMethod?.addInstructions(
MembershipSettingsFingerprint.resultOrThrow().mutableMethod.addInstructions(
0, """
const/4 v0, 0x0
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.resourceid.SharedResourceIdPatch
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.MusicTasteBuilderShelf
import app.revanced.util.exception
import app.revanced.util.getTargetIndex
import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -25,7 +25,7 @@ object TasteBuilderPatch : BaseBytecodePatch(
fingerprints = setOf(TasteBuilderConstructorFingerprint)
) {
override fun execute(context: BytecodeContext) {
TasteBuilderConstructorFingerprint.result?.let { parentResult ->
TasteBuilderConstructorFingerprint.resultOrThrow().let { parentResult ->
TasteBuilderSyntheticFingerprint.resolve(context, parentResult.classDef)
parentResult.mutableMethod.apply {
@ -41,9 +41,9 @@ object TasteBuilderPatch : BaseBytecodePatch(
"""
)
}
} ?: throw TasteBuilderConstructorFingerprint.exception
}
TasteBuilderSyntheticFingerprint.result?.let {
TasteBuilderSyntheticFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.startIndex
val insertRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
@ -53,6 +53,6 @@ object TasteBuilderPatch : BaseBytecodePatch(
"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.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Suppress("unused")
@ -26,7 +26,7 @@ object BlackNavigationBarPatch : BaseBytecodePatch(
) {
override fun execute(context: BytecodeContext) {
TabLayoutFingerprint.result?.let {
TabLayoutFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.endIndex
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
@ -38,7 +38,7 @@ object BlackNavigationBarPatch : BaseBytecodePatch(
"""
)
}
} ?: throw TabLayoutFingerprint.exception
}
SettingsPatch.addMusicPreference(
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.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getTargetIndex
import app.revanced.util.getTargetIndexWithMethodReferenceName
import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
@ -38,7 +38,7 @@ object NavigationBarComponentPatch : BaseBytecodePatch(
/**
* Hide navigation labels
*/
TabLayoutTextFingerprint.result?.let {
TabLayoutTextFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val constIndex = getWideLiteralInstructionIndex(SharedResourceIdPatch.Text1)
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"
)
}
} ?: throw TabLayoutTextFingerprint.exception
}
SettingsPatch.contexts.xmlEditor[RESOURCE_FILE_PATH].use { editor ->
val document = editor.file
@ -71,7 +71,7 @@ object NavigationBarComponentPatch : BaseBytecodePatch(
/**
* Hide navigation bar & buttons
*/
TabLayoutTextFingerprint.result?.let {
TabLayoutTextFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val enumIndex = it.scanResult.patternScanResult!!.startIndex + 3
val enumRegister = getInstruction<OneRegisterInstruction>(enumIndex).registerA
@ -90,7 +90,7 @@ object NavigationBarComponentPatch : BaseBytecodePatch(
"sput-object v$enumRegister, $NAVIGATION_CLASS_DESCRIPTOR->lastPivotTab:Ljava/lang/Enum;"
)
}
} ?: throw TabLayoutTextFingerprint.exception
}
SettingsPatch.addMusicPreference(
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.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getTargetIndex
import app.revanced.util.getTargetIndexReversed
import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.MethodParameter
@ -43,11 +43,11 @@ object ColorMatchPlayerPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) {
MiniPlayerConstructorFingerprint.result?.let { parentResult ->
MiniPlayerConstructorFingerprint.resultOrThrow().let { parentResult ->
// Resolves fingerprints
SwitchToggleColorFingerprint.resolve(context, parentResult.classDef)
SwitchToggleColorFingerprint.result?.let {
SwitchToggleColorFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
methodParameter = parameters
@ -94,8 +94,8 @@ object ColorMatchPlayerPatch : BaseBytecodePatch(
removeInstruction(invokeDirectIndex)
}
}
} ?: throw SwitchToggleColorFingerprint.exception
} ?: throw MiniPlayerConstructorFingerprint.exception
}
}
SettingsPatch.addMusicPreference(
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.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Suppress("unused")
@ -22,7 +22,7 @@ object MinimizedPlayerPatch : BaseBytecodePatch(
) {
override fun execute(context: BytecodeContext) {
MinimizedPlayerFingerprint.result?.let {
MinimizedPlayerFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.endIndex
val insertRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
@ -34,7 +34,7 @@ object MinimizedPlayerPatch : BaseBytecodePatch(
"""
)
}
} ?: throw MinimizedPlayerFingerprint.exception
}
SettingsPatch.addMusicPreference(
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.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getStringInstructionIndex
import app.revanced.util.getTargetIndex
import app.revanced.util.getTargetIndexReversed
import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
@ -81,23 +81,20 @@ object MiniPlayerButtonPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) {
val miniPlayerConstructorMutableMethod =
MiniPlayerConstructorFingerprint.result?.mutableMethod
?: throw MiniPlayerConstructorFingerprint.exception
MiniPlayerConstructorFingerprint.resultOrThrow().mutableMethod
val mppWatchWhileLayoutMutableMethod =
MppWatchWhileLayoutFingerprint.result?.mutableMethod
?: throw MppWatchWhileLayoutFingerprint.exception
MppWatchWhileLayoutFingerprint.resultOrThrow().mutableMethod
val pendingIntentReceiverMutableMethod =
PendingIntentReceiverFingerprint.result?.mutableMethod
?: throw PendingIntentReceiverFingerprint.exception
PendingIntentReceiverFingerprint.resultOrThrow().mutableMethod
if (!SettingsPatch.upward0642) {
MiniPlayerParentFingerprint.result?.let { parentResult ->
MiniPlayerParentFingerprint.resultOrThrow().let { parentResult ->
// Resolves fingerprints
NextButtonVisibilityFingerprint.resolve(context, parentResult.classDef)
NextButtonVisibilityFingerprint.result?.let {
NextButtonVisibilityFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.startIndex + 1
val targetRegister =
@ -110,8 +107,8 @@ object MiniPlayerButtonPatch : BaseBytecodePatch(
"""
)
}
} ?: throw NextButtonVisibilityFingerprint.exception
} ?: throw MiniPlayerParentFingerprint.exception
}
}
} else {
miniPlayerConstructorMutableMethod.setInstanceFieldValue(NEXT_BUTTON_METHOD_NAME, TopStart)
mppWatchWhileLayoutMutableMethod.setStaticFieldValue(NEXT_BUTTON_FIELD_NAME, TopStart)
@ -210,7 +207,7 @@ object MiniPlayerButtonPatch : BaseBytecodePatch(
)
} ?: throw PatchException("onClickClass not found!")
PlayerPatchConstructorFingerprint.result?.let {
PlayerPatchConstructorFingerprint.resultOrThrow().let {
val mutableClass = it.mutableClass
mutableClass.methods.find { method -> method.name == methodName }
?.apply {
@ -227,14 +224,14 @@ object MiniPlayerButtonPatch : BaseBytecodePatch(
)
addInstructionsWithLabels(
0, """
sget-object v0, $PLAYER_CLASS_DESCRIPTOR->$fieldName:$onClickReferenceDefiningClass
if-eqz v0, :ignore
invoke-virtual {v0}, $onClickReference
:ignore
return-void
"""
sget-object v0, $PLAYER_CLASS_DESCRIPTOR->$fieldName:$onClickReferenceDefiningClass
if-eqz v0, :ignore
invoke-virtual {v0}, $onClickReference
:ignore
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.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Suppress("unused")
@ -21,7 +21,7 @@ object RememberRepeatPatch : BaseBytecodePatch(
fingerprints = setOf(RepeatTrackFingerprint)
) {
override fun execute(context: BytecodeContext) {
RepeatTrackFingerprint.result?.let {
RepeatTrackFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.endIndex
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
@ -33,7 +33,7 @@ object RememberRepeatPatch : BaseBytecodePatch(
"""
)
}
} ?: throw RepeatTrackFingerprint.exception
}
SettingsPatch.addMusicPreference(
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.util.ResourceGroup
import app.revanced.util.copyResources
import app.revanced.util.exception
import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
@ -46,7 +46,7 @@ object ReplaceCastButtonPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) {
CastButtonContainerFingerprint.resolve(context, mainActivityClassDef)
CastButtonContainerFingerprint.result?.let {
CastButtonContainerFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val freeIndex = getWideLiteralInstructionIndex(PlayerCastMediaRouteButton) + 1
val freeRegister = getInstruction<OneRegisterInstruction>(freeIndex).registerA
@ -82,7 +82,7 @@ object ReplaceCastButtonPatch : BaseBytecodePatch(
break
}
}
} ?: throw CastButtonContainerFingerprint.exception
}
PlayerResponsePatch.injectPlaylistCall(
"$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.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
@Suppress("unused")
@ -25,7 +25,7 @@ object ShareButtonPatch : BaseBytecodePatch(
fingerprints = setOf(RemixGenericButtonFingerprint)
) {
override fun execute(context: BytecodeContext) {
RemixGenericButtonFingerprint.result?.let {
RemixGenericButtonFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.endIndex
val targetRegister = getInstruction<TwoRegisterInstruction>(targetIndex).registerA
@ -37,7 +37,7 @@ object ShareButtonPatch : BaseBytecodePatch(
"""
)
}
} ?: throw RemixGenericButtonFingerprint.exception
}
SettingsPatch.addMusicPreference(
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.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import app.revanced.util.transformFields
import app.revanced.util.traverseClassHierarchy
import com.android.tools.smali.dexlib2.AccessFlags
@ -48,7 +48,7 @@ object RememberShufflePatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) {
ShuffleClassReferenceFingerprint.result?.let {
ShuffleClassReferenceFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val startIndex = it.scanResult.patternScanResult!!.startIndex
val endIndex = it.scanResult.patternScanResult!!.endIndex
@ -110,9 +110,9 @@ object RememberShufflePatch : BaseBytecodePatch(
).toMutable()
}
}
} ?: throw ShuffleClassReferenceFingerprint.exception
}
MusicPlaybackControlsFingerprint.result?.let {
MusicPlaybackControlsFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
addInstruction(
0,
@ -158,7 +158,7 @@ object RememberShufflePatch : BaseBytecodePatch(
it.mutableClass.methods.add(shuffleMethod)
it.mutableClass.staticFields.add(shuffleField)
}
} ?: throw MusicPlaybackControlsFingerprint.exception
}
SettingsPatch.addMusicPreference(
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.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getReference
import app.revanced.util.getStringInstructionIndex
import app.revanced.util.getTargetIndex
@ -27,6 +26,7 @@ import app.revanced.util.getTargetIndexReversed
import app.revanced.util.getTargetIndexWithFieldReferenceType
import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -67,7 +67,7 @@ object SwipeToDismissMiniPlayerPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) {
if (!SettingsPatch.upward0642) {
SwipeToCloseFingerprint.result?.let {
SwipeToCloseFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val insertIndex = implementation!!.instructions.size - 1
val targetRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
@ -79,21 +79,21 @@ object SwipeToDismissMiniPlayerPatch : BaseBytecodePatch(
"""
)
}
} ?: throw SwipeToCloseFingerprint.exception
}
} else {
// Dismiss mini player by swiping down
InteractionLoggingEnumFingerprint.result?.let {
InteractionLoggingEnumFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val stringIndex = getStringInstructionIndex("INTERACTION_LOGGING_GESTURE_TYPE_SWIPE")
val sPutObjectIndex = getTargetIndex(stringIndex, Opcode.SPUT_OBJECT)
sGetObjectReference = getInstruction<ReferenceInstruction>(sPutObjectIndex).reference
}
} ?: throw InteractionLoggingEnumFingerprint.exception
}
MusicActivityWidgetFingerprint.result?.let {
MusicActivityWidgetFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
widgetIndex = getWideLiteralInstructionIndex(79500)
@ -105,13 +105,13 @@ object SwipeToDismissMiniPlayerPatch : BaseBytecodePatch(
invokeDirectReference = getReference(Opcode.INVOKE_DIRECT, false)
invokeInterfaceSecondaryReference = getReference(Opcode.INVOKE_INTERFACE, false)
}
} ?: throw MusicActivityWidgetFingerprint.exception
}
HandleSearchRenderedFingerprint.result?.let { parentResult ->
HandleSearchRenderedFingerprint.resultOrThrow().let { parentResult ->
// Resolves fingerprints
HandleSignInEventFingerprint.resolve(context, parentResult.classDef)
HandleSignInEventFingerprint.result?.let {
HandleSignInEventFingerprint.resultOrThrow().let {
val dismissBehaviorMethod = context.toMethodWalker(it.method)
.nextMethod(it.scanResult.patternScanResult!!.startIndex, true)
.getMethod() as MutableMethod
@ -145,14 +145,14 @@ object SwipeToDismissMiniPlayerPatch : BaseBytecodePatch(
""", ExternalLabel("dismiss", getInstruction(insertIndex))
)
}
} ?: throw HandleSignInEventFingerprint.exception
} ?: throw HandleSearchRenderedFingerprint.exception
}
}
// Endregion
// Hides default text display when the app is cold started
MiniPlayerDefaultTextFingerprint.result?.let {
MiniPlayerDefaultTextFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.endIndex
val insertRegister = getInstruction<TwoRegisterInstruction>(insertIndex).registerB
@ -164,13 +164,13 @@ object SwipeToDismissMiniPlayerPatch : BaseBytecodePatch(
"""
)
}
} ?: throw MiniPlayerDefaultTextFingerprint.exception
}
// Endregion
// Hides default text display after dismissing the mini player
MiniPlayerDefaultViewVisibilityFingerprint.result?.let {
MiniPlayerDefaultViewVisibilityFingerprint.resultOrThrow().let {
it.mutableClass.methods.find { method ->
method.parameters == listOf("Landroid/view/View;", "I")
}?.apply {
@ -193,7 +193,7 @@ object SwipeToDismissMiniPlayerPatch : BaseBytecodePatch(
)
} ?: throw PatchException("Could not find targetMethod")
} ?: throw MiniPlayerDefaultViewVisibilityFingerprint.exception
}
// 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.SettingsPatch
import app.revanced.patches.music.utils.videotype.VideoTypeHookPatch
import app.revanced.util.exception
import app.revanced.util.getTargetIndex
import app.revanced.util.getWalkerMethod
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -33,7 +33,7 @@ object ZenModePatch : BaseBytecodePatch(
) {
override fun execute(context: BytecodeContext) {
MiniPlayerConstructorFingerprint.result?.let { parentResult ->
MiniPlayerConstructorFingerprint.resultOrThrow().let { parentResult ->
// Resolves fingerprints
SwitchToggleColorFingerprint.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 {
val invokeDirectIndex = getTargetIndex(Opcode.INVOKE_DIRECT)
val walkerMethod = getWalkerMethod(context, invokeDirectIndex)
@ -70,8 +70,8 @@ object ZenModePatch : BaseBytecodePatch(
"""
)
}
} ?: throw SwitchToggleColorFingerprint.exception
} ?: throw MiniPlayerConstructorFingerprint.exception
}
}
SettingsPatch.addMusicPreference(
CategoryType.PLAYER,

View File

@ -4,8 +4,8 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patches.music.utils.fix.androidauto.fingerprints.CertificateCheckFingerprint
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.resultOrThrow
@Suppress("unused")
object AndroidAutoCertificatePatch : BaseBytecodePatch(
@ -16,7 +16,7 @@ object AndroidAutoCertificatePatch : BaseBytecodePatch(
) {
override fun execute(context: BytecodeContext) {
CertificateCheckFingerprint.result?.let {
CertificateCheckFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
addInstructions(
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
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.patches.music.utils.fix.fileprovider.fingerprints.FileProviderResolverFingerprint
import app.revanced.patches.shared.packagename.PackageNamePatch
import app.revanced.util.exception
import app.revanced.util.resultOrThrow
@Patch(dependencies = [PackageNamePatch::class])
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.
*/
FileProviderResolverFingerprint.result?.let {
FileProviderResolverFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
addInstructionsWithLabels(
0, """
@ -40,7 +40,7 @@ object FileProviderPatch : BytecodePatch(
""", 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.patches.music.utils.integrations.Constants.UTILS_PATH
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
object MainActivityResolvePatch : BytecodePatch(
@ -16,10 +16,10 @@ object MainActivityResolvePatch : BytecodePatch(
private lateinit var onCreateMethod: MutableMethod
override fun execute(context: BytecodeContext) {
MainActivityFingerprint.result?.let {
MainActivityFingerprint.resultOrThrow().let {
mainActivityClassDef = it.classDef
onCreateMethod = it.mutableMethod
} ?: throw MainActivityFingerprint.exception
}
}
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.VideoQualityTextFingerprint
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.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
@ -41,7 +41,7 @@ object OverrideQualityHookPatch : BytecodePatch(
override fun execute(context: BytecodeContext) {
VideoQualityListFingerprint.result?.let {
VideoQualityListFingerprint.resultOrThrow().let {
val constructorMethod =
it.mutableClass.methods.first { method -> MethodUtil.isConstructor(method) }
val overrideMethod =
@ -67,9 +67,9 @@ object OverrideQualityHookPatch : BytecodePatch(
"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.mutableClass.staticFields.add(
ImmutableField(
@ -90,9 +90,9 @@ object OverrideQualityHookPatch : BytecodePatch(
"""
)
}
} ?: throw VideoQualityPatchFingerprint.exception
}
VideoQualityTextFingerprint.result?.let {
VideoQualityTextFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val textIndex = it.scanResult.patternScanResult!!.endIndex
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;"
)
}
} ?: 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.PlaybackSpeedParentFingerprint
import app.revanced.patches.music.utils.overridespeed.fingerprints.PlaybackSpeedPatchFingerprint
import app.revanced.util.exception
import app.revanced.util.getTargetIndex
import app.revanced.util.getWalkerMethod
import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -49,7 +49,7 @@ object OverrideSpeedHookPatch : BytecodePatch(
override fun execute(context: BytecodeContext) {
PlaybackSpeedOnClickListenerFingerprint.result?.let {
PlaybackSpeedOnClickListenerFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val startIndex = getWideLiteralInstructionIndex(147448)
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"
)
}
} ?: throw PlaybackSpeedOnClickListenerFingerprint.exception
}
PlaybackSpeedParentFingerprint.result?.let { parentResult ->
PlaybackSpeedParentFingerprint.resultOrThrow().let { parentResult ->
PlaybackSpeedFingerprint.also {
it.resolve(
context,
parentResult.classDef
)
}.result?.let {
}.resultOrThrow().let {
it.mutableMethod.apply {
val startIndex = it.scanResult.patternScanResult!!.startIndex
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.mutableClass.staticFields.add(
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.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.music.utils.playerresponse.fingerprints.PlaybackStartDescriptorFingerprint
import app.revanced.util.exception
import app.revanced.util.resultOrThrow
object PlayerResponsePatch : BytecodePatch(
setOf(PlaybackStartDescriptorFingerprint)
@ -37,8 +37,7 @@ object PlayerResponsePatch : BytecodePatch(
override fun execute(context: BytecodeContext) {
insertMethod = PlaybackStartDescriptorFingerprint.result?.mutableMethod
?: throw PlaybackStartDescriptorFingerprint.exception
insertMethod = PlaybackStartDescriptorFingerprint.resultOrThrow().mutableMethod
}

View File

@ -5,25 +5,24 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patches.music.utils.integrations.Constants.UTILS_PATH
import app.revanced.patches.music.utils.playertype.fingerprint.PlayerTypeFingerprint
import app.revanced.util.exception
import app.revanced.util.resultOrThrow
@Suppress("unused")
object PlayerTypeHookPatch : BytecodePatch(
setOf(PlayerTypeFingerprint)
) {
private const val INTEGRATIONS_CLASS_DESCRIPTOR =
"$UTILS_PATH/PlayerTypeHookPatch;"
override fun execute(context: BytecodeContext) {
PlayerTypeFingerprint.result?.let {
PlayerTypeFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
addInstruction(
0,
"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.TextComponentFingerprint
import app.revanced.patches.music.video.videoid.VideoIdPatch
import app.revanced.util.exception
import app.revanced.util.indexOfFirstInstruction
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
@ -42,18 +42,16 @@ object ReturnYouTubeDislikeBytecodePatch : BytecodePatch(
DislikeFingerprint.toPatch(Vote.DISLIKE),
RemoveLikeFingerprint.toPatch(Vote.REMOVE_LIKE)
).forEach { (fingerprint, vote) ->
with(fingerprint.result ?: throw fingerprint.exception) {
mutableMethod.addInstructions(
0,
"""
fingerprint.resultOrThrow().mutableMethod.addInstructions(
0,
"""
const/4 v0, ${vote.value}
invoke-static {v0}, $INTEGRATIONS_RYD_CLASS_DESCRIPTOR->sendVote(I)V
"""
)
}
)
}
TextComponentFingerprint.result?.let {
TextComponentFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val insertIndex = indexOfFirstInstruction {
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")

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.SettingsHeadersFragmentFingerprint
import app.revanced.patches.shared.settings.fingerprints.SharedSettingFingerprint
import app.revanced.util.exception
import app.revanced.util.getTargetIndex
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -47,7 +47,7 @@ object SettingsBytecodePatch : BytecodePatch(
/**
* Set SharedPrefCategory
*/
SharedSettingFingerprint.result?.let {
SharedSettingFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val stringIndex = getTargetIndex(Opcode.CONST_STRING)
val stringRegister = getInstruction<OneRegisterInstruction>(stringIndex).registerA
@ -57,12 +57,12 @@ object SettingsBytecodePatch : BytecodePatch(
"const-string v$stringRegister, \"youtube\""
)
}
} ?: throw SharedSettingFingerprint.exception
}
/**
* Inject settings Activity
*/
SettingsHeadersFragmentFingerprint.result?.let {
SettingsHeadersFragmentFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.endIndex
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"
)
}
} ?: throw SettingsHeadersFragmentFingerprint.exception
}
/**
* Values are loaded when preferences change
*/
PreferenceFingerprint.result?.let {
PreferenceFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.endIndex
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"
)
}
} ?: throw PreferenceFingerprint.exception
}
/**
* Inject dummy Activity for intent
*/
GoogleApiActivityFingerprint.result?.let {
GoogleApiActivityFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
addInstructionsWithLabels(
1, """
@ -104,7 +104,7 @@ object SettingsBytecodePatch : BytecodePatch(
""", ExternalLabel("show", getInstruction(1))
)
}
} ?: throw GoogleApiActivityFingerprint.exception
}
injectInit("InitializationPatch", "setDeviceInformation")
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.video.information.VideoInformationPatch
import app.revanced.patches.music.video.videoid.VideoIdPatch
import app.revanced.util.exception
import app.revanced.util.getTargetIndexWithMethodReferenceName
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.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
@ -55,11 +55,10 @@ object SponsorBlockBytecodePatch : BytecodePatch(
/**
* Responsible for seekbar in fullscreen
*/
val seekBarClass = SeekBarConstructorFingerprint.result?.mutableClass
?: throw SeekBarConstructorFingerprint.exception
val seekBarClass = SeekBarConstructorFingerprint.resultOrThrow().mutableClass
SeekbarOnDrawFingerprint.resolve(context, seekBarClass)
SeekbarOnDrawFingerprint.result?.let {
SeekbarOnDrawFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
// Initialize seekbar method
addInstructions(
@ -88,22 +87,22 @@ object SponsorBlockBytecodePatch : BytecodePatch(
"$INTEGRATIONS_SEGMENT_PLAYBACK_CONTROLLER_CLASS_DESCRIPTOR->drawSponsorTimeBars(Landroid/graphics/Canvas;F)V"
)
}
} ?: throw SeekbarOnDrawFingerprint.exception
}
/**
* Responsible for seekbar in player
*/
MusicPlaybackControlsTimeBarOnMeasureFingerprint.result?.let {
MusicPlaybackControlsTimeBarOnMeasureFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val rectangleIndex = it.scanResult.patternScanResult!!.startIndex
val rectangleReference =
getInstruction<ReferenceInstruction>(rectangleIndex).reference
rectangleFieldName = (rectangleReference as FieldReference).name
}
} ?: throw MusicPlaybackControlsTimeBarOnMeasureFingerprint.exception
}
MusicPlaybackControlsTimeBarDrawFingerprint.result?.let {
MusicPlaybackControlsTimeBarDrawFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
// Initialize seekbar method
addInstructions(
@ -123,7 +122,7 @@ object SponsorBlockBytecodePatch : BytecodePatch(
"$INTEGRATIONS_SEGMENT_PLAYBACK_CONTROLLER_CLASS_DESCRIPTOR->drawSponsorTimeBars(Landroid/graphics/Canvas;F)V"
)
}
} ?: throw MusicPlaybackControlsTimeBarDrawFingerprint.exception
}
/**
* 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.videotype.fingerprint.VideoTypeFingerprint
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
@Suppress("SpellCheckingInspection", "unused")
@ -19,13 +19,13 @@ object VideoTypeHookPatch : BytecodePatch(
override fun execute(context: BytecodeContext) {
VideoTypeParentFingerprint.result?.let { parentResult ->
VideoTypeParentFingerprint.resultOrThrow().let { parentResult ->
VideoTypeFingerprint.also {
it.resolve(
context,
parentResult.classDef
)
}.result?.let {
}.resultOrThrow().let {
it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.startIndex + 3
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.VideoLengthFingerprint
import app.revanced.patches.music.video.videoid.VideoIdPatch
import app.revanced.util.exception
import app.revanced.util.getTargetIndexWithFieldReferenceTypeReversed
import app.revanced.util.getTargetIndexWithMethodReferenceNameReversed
import app.revanced.util.getWalkerMethod
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.builder.MutableMethodImplementation
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -90,7 +90,7 @@ object VideoInformationPatch : BytecodePatch(
)
override fun execute(context: BytecodeContext) {
VideoEndFingerprint.result?.let {
VideoEndFingerprint.resultOrThrow().let {
playerInitMethod =
it.mutableClass.methods.first { method -> MethodUtil.isConstructor(method) }
@ -120,19 +120,19 @@ object VideoInformationPatch : BytecodePatch(
)
it.mutableClass.methods.add(seekHelperMethod)
}
} ?: throw VideoEndFingerprint.exception
}
/**
* Set current video length
*/
SeekBarConstructorFingerprint.result?.classDef?.let { classDef ->
SeekBarConstructorFingerprint.resultOrThrow().classDef.let { classDef ->
VideoLengthFingerprint.also {
it.resolve(
context,
classDef
)
}.result?.let {
}.resultOrThrow().let {
it.mutableMethod.apply {
val invalidateIndex = getTargetIndexWithMethodReferenceNameReversed("invalidate")
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"
)
}
} ?: throw VideoLengthFingerprint.exception
} ?: throw SeekBarConstructorFingerprint.exception
}
}
/**
* Set the video time method
*/
PlayerControllerSetTimeReferenceFingerprint.result?.let {
PlayerControllerSetTimeReferenceFingerprint.resultOrThrow().let {
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.video.quality.fingerprints.UserQualityChangeFingerprint
import app.revanced.patches.music.video.videoid.VideoIdPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction21c
@Suppress("unused")
@ -32,7 +32,7 @@ object VideoQualityPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) {
UserQualityChangeFingerprint.result?.let {
UserQualityChangeFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val endIndex = it.scanResult.patternScanResult!!.endIndex
val qualityChangedClass =
@ -54,7 +54,7 @@ object VideoQualityPatch : BaseBytecodePatch(
)
} ?: throw PatchException("Failed to find onItemClick method")
}
} ?: throw UserQualityChangeFingerprint.exception
}
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.video.speed.fingerprints.PlaybackSpeedBottomSheetFingerprint
import app.revanced.patches.music.video.speed.fingerprints.PlaybackSpeedBottomSheetParentFingerprint
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
@Suppress("unused")
@ -30,13 +30,13 @@ object PlaybackSpeedPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) {
PlaybackSpeedBottomSheetParentFingerprint.result?.let { parentResult ->
PlaybackSpeedBottomSheetParentFingerprint.resultOrThrow().let { parentResult ->
PlaybackSpeedBottomSheetFingerprint.also {
it.resolve(
context,
parentResult.classDef
)
}.result?.let {
}.resultOrThrow().let {
it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.startIndex
val targetRegister =
@ -47,8 +47,8 @@ object PlaybackSpeedPatch : BaseBytecodePatch(
"invoke-static {v$targetRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->userChangedSpeed(F)V"
)
}
} ?: throw PlaybackSpeedBottomSheetFingerprint.exception
} ?: throw PlaybackSpeedBottomSheetParentFingerprint.exception
}
}
SettingsPatch.addMusicPreference(
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.patches.music.video.videoid.fingerprints.PlayerResponseModelStoryboardRendererFingerprint
import app.revanced.patches.music.video.videoid.fingerprints.VideoIdParentFingerprint
import app.revanced.util.exception
import app.revanced.util.getTargetIndexReversed
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
@ -36,7 +36,7 @@ object VideoIdPatch : BytecodePatch(
override fun execute(context: BytecodeContext) {
VideoIdParentFingerprint.result?.let { result ->
VideoIdParentFingerprint.resultOrThrow().let { result ->
val targetIndex = result.scanResult.patternScanResult!!.endIndex
val targetReference = result.mutableMethod.getInstruction<ReferenceInstruction>(targetIndex).reference
val targetClass = (targetReference as FieldReference).type
@ -55,14 +55,17 @@ object VideoIdPatch : BytecodePatch(
videoIdRegister = getInstruction<OneRegisterInstruction>(videoIdInsertIndex - 1).registerA
}
} ?: throw VideoIdParentFingerprint.exception
}
PlayerResponseModelStoryboardRendererFingerprint.result
?.mutableClass?.methods?.find { method -> method.name == backgroundPlaybackMethodName }
PlayerResponseModelStoryboardRendererFingerprint
.resultOrThrow()
.mutableClass
.methods
.find { method -> method.name == backgroundPlaybackMethodName }
?.apply {
backgroundPlaybackMethod = this
backgroundPlaybackInsertIndex = implementation!!.instructions.size - 1
} ?: throw PlayerResponseModelStoryboardRendererFingerprint.exception
}
}
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.patches.reddit.ad.comments.fingerprints.CommentAdsFingerprint
import app.revanced.patches.reddit.utils.integrations.Constants.PATCHES_PATH
import app.revanced.util.exception
import app.revanced.util.getWalkerMethod
import app.revanced.util.resultOrThrow
object CommentAdsPatch : BytecodePatch(
setOf(CommentAdsFingerprint)
@ -17,7 +17,7 @@ object CommentAdsPatch : BytecodePatch(
"$PATCHES_PATH/GeneralAdsPatch;->hideCommentAds()Z"
override fun execute(context: BytecodeContext) {
CommentAdsFingerprint.result?.apply {
CommentAdsFingerprint.resultOrThrow().apply {
val walkerMethod = getWalkerMethod(context, scanResult.patternScanResult!!.startIndex)
walkerMethod.apply {
addInstructionsWithLabels(
@ -31,7 +31,7 @@ object CommentAdsPatch : BytecodePatch(
""", 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.settings.SettingsBytecodePatch.updateSettingsStatus
import app.revanced.patches.reddit.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getTargetIndexWithFieldReferenceName
import app.revanced.util.getTargetIndexWithMethodReferenceName
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.TwoRegisterInstruction
@ -41,7 +41,7 @@ object AdsPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) {
// region Filter promoted ads (does not work in popular or latest feed)
AdPostFingerprint.result?.let {
AdPostFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val targetIndex = getTargetIndexWithFieldReferenceName("children")
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.
// AdElementConverter is conveniently responsible for inserting all feed ads.
// By removing the appending instruction no ad posts gets appended to the feed.
NewAdPostFingerprint.result?.let {
NewAdPostFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val targetIndex = getTargetIndexWithMethodReferenceName("add")
val targetRegister =
@ -72,7 +72,7 @@ object AdsPatch : BaseBytecodePatch(
""", ExternalLabel("show", getInstruction(targetIndex + 1))
)
}
} ?: throw NewAdPostFingerprint.exception
}
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.settings.SettingsBytecodePatch.updateSettingsStatus
import app.revanced.patches.reddit.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
@Suppress("unused")
@ -25,7 +25,7 @@ object NavigationButtonsPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) {
BottomNavScreenFingerprint.result?.let {
BottomNavScreenFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val startIndex = it.scanResult.patternScanResult!!.startIndex
val targetRegister =
@ -36,7 +36,7 @@ object NavigationButtonsPatch : BaseBytecodePatch(
"invoke-static {v$targetRegister}, $INTEGRATIONS_METHOD_DESCRIPTOR"
)
}
} ?: throw BottomNavScreenFingerprint.exception
}
updateSettingsStatus("enableNavigationButtons")

View File

@ -4,8 +4,8 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patches.reddit.layout.premiumicon.fingerprints.PremiumIconFingerprint
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.resultOrThrow
@Suppress("unused")
object PremiumIconPatch : BaseBytecodePatch(
@ -16,7 +16,7 @@ object PremiumIconPatch : BaseBytecodePatch(
) {
override fun execute(context: BytecodeContext) {
PremiumIconFingerprint.result?.let {
PremiumIconFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
addInstructions(
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.settings.SettingsBytecodePatch.updateSettingsStatus
import app.revanced.patches.reddit.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getTargetIndex
import app.revanced.util.getTargetIndexReversed
import app.revanced.util.getTargetIndexWithFieldReferenceName
import app.revanced.util.getTargetIndexWithReference
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
@ -35,7 +35,7 @@ object RecentlyVisitedShelfPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) {
CommunityDrawerPresenterFingerprint.result?.let {
CommunityDrawerPresenterFingerprint.resultOrThrow().let {
lateinit var recentlyVisitedReference: Reference
it.mutableClass.methods.find { method -> method.name == "<init>" }
@ -63,7 +63,7 @@ object RecentlyVisitedShelfPatch : BaseBytecodePatch(
)
}
}
} ?: throw CommunityDrawerPresenterFingerprint.exception
}
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.settings.SettingsBytecodePatch.updateSettingsStatus
import app.revanced.patches.reddit.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
@Suppress("unused")
object ScreenshotPopupPatch : BaseBytecodePatch(
@ -29,7 +29,7 @@ object ScreenshotPopupPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) {
ScreenshotTakenBannerFingerprint.result?.let {
ScreenshotTakenBannerFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
addInstructionsWithLabels(
0, """
@ -40,7 +40,7 @@ object ScreenshotPopupPatch : BaseBytecodePatch(
""", ExternalLabel("dismiss", getInstruction(0))
)
}
} ?: throw ScreenshotTakenBannerFingerprint.exception
}
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.settings.SettingsBytecodePatch.updateSettingsStatus
import app.revanced.patches.reddit.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getWideLiteralInstructionIndex
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.OneRegisterInstruction
@ -37,7 +37,7 @@ object SubRedditDialogPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) {
FrequentUpdatesSheetScreenFingerprint.result?.let {
FrequentUpdatesSheetScreenFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val cancelButtonViewIndex = getWideLiteralInstructionIndex(CancelButton) + 2
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"
)
}
} ?: throw FrequentUpdatesSheetScreenFingerprint.exception
}
RedditAlertDialogsFingerprint.result?.let {
RedditAlertDialogsFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val insertIndex = getWideLiteralInstructionIndex(TextAppearanceRedditBaseOldButtonColored) + 1
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"
)
}
} ?: throw RedditAlertDialogsFingerprint.exception
}
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.settings.SettingsBytecodePatch.updateSettingsStatus
import app.revanced.patches.reddit.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Suppress("unused")
@ -31,7 +31,7 @@ object ToolBarButtonPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) {
HomePagerScreenFingerprint.result?.let {
HomePagerScreenFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val targetIndex =
getWideLiteralInstructionIndex(ToolBarNavSearchCtaContainer) + 3
@ -43,7 +43,7 @@ object ToolBarButtonPatch : BaseBytecodePatch(
"invoke-static {v$targetRegister}, $INTEGRATIONS_METHOD_DESCRIPTOR"
)
}
} ?: throw HomePagerScreenFingerprint.exception
}
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.settings.SettingsBytecodePatch.updateSettingsStatus
import app.revanced.patches.reddit.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
@Suppress("unused")
object OpenLinksDirectlyPatch : BaseBytecodePatch(
@ -24,7 +24,7 @@ object OpenLinksDirectlyPatch : BaseBytecodePatch(
"parseRedirectUri(Landroid/net/Uri;)Landroid/net/Uri;"
override fun execute(context: BytecodeContext) {
ScreenNavigatorFingerprint.result?.let {
ScreenNavigatorFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
addInstructions(
0, """
@ -33,7 +33,7 @@ object OpenLinksDirectlyPatch : BaseBytecodePatch(
"""
)
}
} ?: throw ScreenNavigatorFingerprint.exception
}
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.settings.SettingsBytecodePatch.updateSettingsStatus
import app.revanced.patches.reddit.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getStringInstructionIndex
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
@Suppress("unused")
object OpenLinksExternallyPatch : BaseBytecodePatch(
@ -25,7 +25,7 @@ object OpenLinksExternallyPatch : BaseBytecodePatch(
"$PATCHES_PATH/OpenLinksExternallyPatch;"
override fun execute(context: BytecodeContext) {
ScreenNavigatorFingerprint.result?.let {
ScreenNavigatorFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val insertIndex = getStringInstructionIndex("uri") + 2
@ -38,7 +38,7 @@ object OpenLinksExternallyPatch : BaseBytecodePatch(
""", ExternalLabel("dismiss", getInstruction(insertIndex))
)
}
} ?: throw ScreenNavigatorFingerprint.exception
}
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.settings.SettingsBytecodePatch.updateSettingsStatus
import app.revanced.patches.reddit.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
@Suppress("unused")
object SanitizeUrlQueryPatch : BaseBytecodePatch(
@ -24,7 +24,7 @@ object SanitizeUrlQueryPatch : BaseBytecodePatch(
"$PATCHES_PATH/SanitizeUrlQueryPatch;->stripQueryParameters()Z"
override fun execute(context: BytecodeContext) {
ShareLinkFormatterFingerprint.result?.let { result ->
ShareLinkFormatterFingerprint.resultOrThrow().let { result ->
result.mutableMethod.apply {
addInstructionsWithLabels(
0,
@ -36,7 +36,7 @@ object SanitizeUrlQueryPatch : BaseBytecodePatch(
""", ExternalLabel("off", getInstruction(0))
)
}
} ?: throw ShareLinkFormatterFingerprint.exception
}
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.SettingsStatusLoadFingerprint
import app.revanced.patches.shared.settings.fingerprints.SharedSettingFingerprint
import app.revanced.util.exception
import app.revanced.util.getTargetIndex
import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -47,7 +47,7 @@ object SettingsBytecodePatch : BytecodePatch(
/**
* Set SharedPrefCategory
*/
SharedSettingFingerprint.result?.let {
SharedSettingFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val stringIndex = getTargetIndex(Opcode.CONST_STRING)
val stringRegister = getInstruction<OneRegisterInstruction>(stringIndex).registerA
@ -57,12 +57,12 @@ object SettingsBytecodePatch : BytecodePatch(
"const-string v$stringRegister, \"reddit_revanced\""
)
}
} ?: throw SharedSettingFingerprint.exception
}
/**
* Replace settings label
*/
AcknowledgementsLabelBuilderFingerprint.result?.let {
AcknowledgementsLabelBuilderFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val insertIndex =
getWideLiteralInstructionIndex(LabelAcknowledgements) + 3
@ -74,12 +74,12 @@ object SettingsBytecodePatch : BytecodePatch(
"const-string v$insertRegister, \"ReVanced Extended\""
)
}
} ?: throw AcknowledgementsLabelBuilderFingerprint.exception
}
/**
* Initialize settings activity
*/
OssLicensesMenuActivityOnCreateFingerprint.result?.let {
OssLicensesMenuActivityOnCreateFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.startIndex + 1
@ -90,10 +90,9 @@ object SettingsBytecodePatch : BytecodePatch(
"""
)
}
} ?: throw OssLicensesMenuActivityOnCreateFingerprint.exception
}
settingsStatusLoadMethod = SettingsStatusLoadFingerprint.result?.mutableMethod
?: throw SettingsStatusLoadFingerprint.exception
settingsStatusLoadMethod = SettingsStatusLoadFingerprint.resultOrThrow().mutableMethod
}
}

View File

@ -8,9 +8,9 @@ import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.shared.ads.fingerprints.MusicAdsFingerprint
import app.revanced.patches.shared.ads.fingerprints.VideoAdsFingerprint
import app.revanced.util.exception
import app.revanced.util.getWalkerMethod
import app.revanced.util.indexOfFirstInstruction
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
@ -25,7 +25,7 @@ abstract class BaseAdsPatch(
)
) {
override fun execute(context: BytecodeContext) {
MusicAdsFingerprint.result?.let {
MusicAdsFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val targetIndex = indexOfFirstInstruction {
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 {
addInstructionsWithLabels(
0, """
@ -57,6 +57,6 @@ abstract class BaseAdsPatch(
""", 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.patches.shared.captions.fingerprints.StartVideoInformerFingerprint
import app.revanced.patches.shared.captions.fingerprints.SubtitleTrackFingerprint
import app.revanced.util.exception
import app.revanced.util.getWalkerMethod
import app.revanced.util.indexOfFirstInstruction
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
@ -25,16 +25,16 @@ abstract class BaseAutoCaptionsPatch(
) {
override fun execute(context: BytecodeContext) {
StartVideoInformerFingerprint.result?.let {
StartVideoInformerFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
addInstruction(
0,
"invoke-static {}, $classDescriptor->prefetchSubtitleTrack()V"
)
}
} ?: throw StartVideoInformerFingerprint.exception
}
SubtitleTrackFingerprint.result?.let {
SubtitleTrackFingerprint.resultOrThrow().let {
val targetMethod = it.getWalkerMethod(context, it.scanResult.patternScanResult!!.startIndex + 1)
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.reference.MethodReference
abstract class AbstractClientSpoofPatch(
abstract class BaseClientSpoofPatch(
private val packageName: String
) : BaseTransformInstructionsPatch<Instruction35cInfo>() {
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.SpeedLimiterFallBackFingerprint
import app.revanced.patches.shared.customspeed.fingerprints.SpeedLimiterFingerprint
import app.revanced.util.exception
import app.revanced.util.getTargetIndexWithFieldReferenceType
import app.revanced.util.getTargetIndexWithMethodReferenceName
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.OneRegisterInstruction
@ -25,9 +25,9 @@ abstract class BaseCustomPlaybackSpeedPatch(
)
) {
override fun execute(context: BytecodeContext) {
SpeedArrayGeneratorFingerprint.result?.let { result ->
result.mutableMethod.apply {
val targetIndex = result.scanResult.patternScanResult!!.startIndex
SpeedArrayGeneratorFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.startIndex
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
addInstructions(
@ -57,13 +57,11 @@ abstract class BaseCustomPlaybackSpeedPatch(
"""
)
}
} ?: throw SpeedArrayGeneratorFingerprint.exception
}
val speedLimiterParentResult = SpeedLimiterFallBackFingerprint.result
?: throw SpeedLimiterFallBackFingerprint.exception
val speedLimiterParentResult = SpeedLimiterFallBackFingerprint.resultOrThrow()
SpeedLimiterFingerprint.resolve(context, speedLimiterParentResult.classDef)
val speedLimiterResult = SpeedLimiterFingerprint.result
?: throw SpeedLimiterFingerprint.exception
val speedLimiterResult = SpeedLimiterFingerprint.resultOrThrow()
arrayOf(
speedLimiterParentResult,

View File

@ -7,9 +7,9 @@ import app.revanced.patcher.fingerprint.MethodFingerprint
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.shared.dialog.fingerprints.CreateDialogFingerprint
import app.revanced.util.exception
import app.revanced.util.getTargetIndexWithMethodReferenceName
import app.revanced.util.getWalkerMethod
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
abstract class BaseViewerDiscretionDialogPatch(
@ -38,15 +38,14 @@ abstract class BaseViewerDiscretionDialogPatch(
}
override fun execute(context: BytecodeContext) {
CreateDialogFingerprint.result?.mutableMethod?.invoke(false)
?: throw CreateDialogFingerprint.exception
CreateDialogFingerprint.resultOrThrow().mutableMethod.invoke(false)
if (additionalFingerprints.isNotEmpty()) {
additionalFingerprints.forEach { fingerprint ->
fingerprint.result?.let {
fingerprint.resultOrThrow().let {
it.getWalkerMethod(context, it.scanResult.patternScanResult!!.endIndex - 1)
.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.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.shared.drawable.fingerprints.DrawableFingerprint
import app.revanced.util.exception
import app.revanced.util.getTargetIndexWithMethodReferenceNameReversed
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
object DrawableColorPatch : BytecodePatch(
@ -15,11 +15,11 @@ object DrawableColorPatch : BytecodePatch(
) {
override fun execute(context: BytecodeContext) {
DrawableFingerprint.result?.mutableMethod?.apply {
DrawableFingerprint.resultOrThrow().mutableMethod?.apply {
insertMethod = this
insertIndex = getTargetIndexWithMethodReferenceNameReversed("setColor")
insertRegister = getInstruction<FiveRegisterInstruction>(insertIndex).registerD
} ?: throw DrawableFingerprint.exception
}
}
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.fingerprint.MethodFingerprint
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.AUTHORITIES
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.packagename.PackageNamePatch
import app.revanced.util.exception
import app.revanced.util.getReference
import app.revanced.util.resultOrThrow
import app.revanced.util.returnEarly
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction21c
@ -98,17 +104,16 @@ abstract class BaseGmsCoreSupportPatch(
).returnEarly()
// 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).
"invoke-static/range { p0 .. p0 }, $INTEGRATIONS_PATH/patches/GmsCoreSupport;->" +
"checkGmsCore(Landroid/content/Context;)V",
) ?: throw mainActivityOnCreateFingerprint.exception
"checkGmsCore(Landroid/content/Context;)V",
)
// Change the vendor of GmsCore in ReVanced Integrations.
GmsCoreSupportFingerprint.result?.mutableClass?.methods
?.single { it.name == GET_GMS_CORE_VENDOR_GROUP_ID_METHOD_NAME }
?.replaceInstruction(0, "const-string v0, \"$gmsCoreVendorGroupId\"")
?: throw GmsCoreSupportFingerprint.exception
GmsCoreSupportFingerprint.resultOrThrow().mutableClass.methods
.single { it.name == GET_GMS_CORE_VENDOR_GROUP_ID_METHOD_NAME }
.replaceInstruction(0, "const-string v0, \"$gmsCoreVendorGroupId\"")
}
private fun BytecodeContext.transformStringReferences(transform: (str: String) -> String?) = classes.forEach {
@ -193,7 +198,7 @@ abstract class BaseGmsCoreSupportPatch(
}
private fun transformPrimeMethod(packageName: String) {
PrimeMethodFingerprint.result?.mutableMethod?.apply {
PrimeMethodFingerprint.resultOrThrow().mutableMethod.apply {
var register = 2
val index = getInstructions().indexOfFirst {
@ -204,7 +209,7 @@ abstract class BaseGmsCoreSupportPatch(
}
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.patches.shared.integrations.BaseIntegrationsPatch.IntegrationsFingerprint.IRegisterResolver
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.iface.ClassDef
import com.android.tools.smali.dexlib2.iface.Method
@ -83,16 +84,16 @@ abstract class BaseIntegrationsPatch(
)
fun invoke(integrationsDescriptor: String) {
result?.mutableMethod?.let { method ->
resultOrThrow().mutableMethod.let { method ->
val insertIndex = insertIndexResolver(method)
val contextRegister = contextRegisterResolver(method)
method.addInstruction(
insertIndex,
"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 {

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.PathBuilderFingerprint
import app.revanced.patches.shared.litho.fingerprints.SetByteBufferFingerprint
import app.revanced.util.exception
import app.revanced.util.getEmptyStringInstructionIndex
import app.revanced.util.getTargetIndex
import app.revanced.util.getTargetIndexReversed
import app.revanced.util.getTargetIndexWithFieldReferenceType
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction35c
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
@ -44,7 +44,7 @@ object LithoFilterPatch : BytecodePatch(
override fun execute(context: BytecodeContext) {
SetByteBufferFingerprint.result?.let {
SetByteBufferFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
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"
)
}
} ?: throw SetByteBufferFingerprint.exception
}
PathBuilderFingerprint.result?.let {
PathBuilderFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val emptyComponentMethodIndex = it.scanResult.patternScanResult!!.startIndex + 1
val emptyComponentMethodReference =
@ -89,9 +89,9 @@ object LithoFilterPatch : BytecodePatch(
""", ExternalLabel("filter", getInstruction(insertIndex))
)
}
} ?: throw PathBuilderFingerprint.exception
}
LithoFilterPatchConstructorFingerprint.result?.let {
LithoFilterPatchConstructorFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
removeInstructions(0, 6)
@ -106,7 +106,7 @@ object LithoFilterPatch : BytecodePatch(
)
}
}
} ?: throw LithoFilterPatchConstructorFingerprint.exception
}
}
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.patches.shared.opus.fingerprints.CodecReferenceFingerprint
import app.revanced.patches.shared.opus.fingerprints.CodecSelectorFingerprint
import app.revanced.util.exception
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.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.reference.Reference
@ -25,14 +25,14 @@ abstract class BaseOpusCodecsPatch(
override fun execute(context: BytecodeContext) {
CodecReferenceFingerprint.result?.let {
CodecReferenceFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val targetIndex = getTargetIndexWithReference("Ljava/util/Set;")
targetReference = getInstruction<ReferenceInstruction>(targetIndex).reference
}
} ?: throw CodecReferenceFingerprint.exception
}
CodecSelectorFingerprint.result?.let {
CodecSelectorFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.endIndex
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
@ -47,6 +47,6 @@ abstract class BaseOpusCodecsPatch(
""", 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.patches.shared.spoofappversion.fingerprints.ClientInfoFingerprint
import app.revanced.patches.shared.spoofappversion.fingerprints.ClientInfoParentFingerprint
import app.revanced.util.exception
import app.revanced.util.getTargetIndexReversed
import app.revanced.util.getTargetIndexWithFieldReferenceName
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
@ -19,10 +19,10 @@ abstract class BaseSpoofAppVersionPatch(
) {
override fun execute(context: BytecodeContext) {
ClientInfoParentFingerprint.result?.let { parentResult ->
ClientInfoParentFingerprint.resultOrThrow().let { parentResult ->
ClientInfoFingerprint.resolve(context, parentResult.classDef)
ClientInfoFingerprint.result?.let {
ClientInfoFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val versionIndex = getTargetIndexWithFieldReferenceName("RELEASE") + 1
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.fingerprint.MethodFingerprint
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
abstract class BaseSanitizeUrlQueryPatch(
@ -19,7 +19,7 @@ abstract class BaseSanitizeUrlQueryPatch(
}
) {
private fun MethodFingerprint.invoke() {
result?.let {
resultOrThrow().let {
it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.startIndex
val targetRegister = getInstruction<TwoRegisterInstruction>(targetIndex).registerA
@ -31,7 +31,7 @@ abstract class BaseSanitizeUrlQueryPatch(
"""
)
}
} ?: throw exception
}
}
override fun execute(context: BytecodeContext) {

View File

@ -1,7 +1,7 @@
package app.revanced.patches.shared.translations
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.StandardCopyOption
@ -13,12 +13,10 @@ object TranslationsUtils {
) {
languageArray.forEach { language ->
val directory = "values-$language-v21"
val relativePath = "$language/strings.xml"
this["res/$directory"].mkdir()
Files.copy(
classLoader.getResourceAsStream("$sourceDirectory/translations/$relativePath")!!,
inputStreamFromBundledResource("$sourceDirectory/translations", "$language/strings.xml")!!,
this["res"].resolve("$directory/strings.xml").toPath(),
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.resourceid.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.InterstitialsContainer
import app.revanced.util.exception
import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Patch(dependencies = [SharedResourceIdPatch::class])
@ -31,7 +31,7 @@ object FullscreenAdsPatch : BytecodePatch(
* Hides fullscreen ads
* Non-litho view, used in some old clients.
*/
InterstitialsContainerFingerprint.result?.let {
InterstitialsContainerFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val targetIndex = getWideLiteralInstructionIndex(InterstitialsContainer) + 2
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"
)
}
} ?: throw InterstitialsContainerFingerprint.exception
}
/**
* Hides fullscreen ads
* Litho view, used in 'ShowDialogCommandOuterClass' in innertube
*/
ShowDialogCommandFingerprint.result?.let {
ShowDialogCommandFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
// In this method, custom dialog is created and shown.
// 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.patches.youtube.ads.getpremium.fingerprints.CompactYpcOfferModuleViewFingerprint
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
object GetPremiumPatch : BytecodePatch(
@ -18,7 +18,7 @@ object GetPremiumPatch : BytecodePatch(
override fun execute(context: BytecodeContext) {
CompactYpcOfferModuleViewFingerprint.result?.let {
CompactYpcOfferModuleViewFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val startIndex = it.scanResult.patternScanResult!!.startIndex
val measuredWidthRegister =
@ -38,7 +38,7 @@ object GetPremiumPatch : BytecodePatch(
""", 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.contexts
import app.revanced.util.copyXmlNode
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.builder.MutableMethodImplementation
@ -90,11 +90,8 @@ object AlternativeThumbnailsPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) {
fun MethodFingerprint.getResultOrThrow() =
result ?: throw exception
fun MethodFingerprint.alsoResolve(fingerprint: MethodFingerprint) =
also { resolve(context, fingerprint.getResultOrThrow().classDef) }.getResultOrThrow()
also { resolve(context, fingerprint.resultOrThrow().classDef) }.resultOrThrow()
fun MethodFingerprint.resolveAndLetMutableMethod(
fingerprint: MethodFingerprint,
@ -118,7 +115,7 @@ object AlternativeThumbnailsPatch : BaseBytecodePatch(
// 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.
RequestFingerprint.getResultOrThrow().apply {
RequestFingerprint.resultOrThrow().apply {
// The url is the only string field that is set inside the constructor.
val urlFieldInstruction = mutableMethod.getInstructions().first {
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.resourceid.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getTargetIndex
import app.revanced.util.getWalkerMethod
import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -41,7 +41,7 @@ object CommentComponentPatch : BaseBytecodePatch(
"$COMPONENTS_PATH/CommentsFilter;"
override fun execute(context: BytecodeContext) {
ShortsLiveStreamEmojiPickerOpacityFingerprint.result?.let {
ShortsLiveStreamEmojiPickerOpacityFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val insertIndex = implementation!!.instructions.size - 1
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"
)
}
} ?: throw ShortsLiveStreamEmojiPickerOpacityFingerprint.exception
}
ShortsLiveStreamEmojiPickerOnClickListenerFingerprint.result?.let { parentResult ->
ShortsLiveStreamEmojiPickerOnClickListenerFingerprint.resultOrThrow().let { parentResult ->
parentResult.mutableMethod.apply {
val emojiPickerEndpointIndex = getWideLiteralInstructionIndex(126326492)
val emojiPickerOnClickListenerIndex = getTargetIndex(emojiPickerEndpointIndex, Opcode.INVOKE_DIRECT)
@ -77,7 +77,7 @@ object CommentComponentPatch : BaseBytecodePatch(
context,
parentResult.classDef
)
}.result?.let {
}.resultOrThrow().let {
it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.startIndex
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.resourceid.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
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.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c
@ -40,8 +40,7 @@ object FeedFlyoutPanelPatch : BaseBytecodePatch(
* Phone
*/
val bottomSheetMenuItemBuilderResult = BottomSheetMenuItemBuilderLegacyFingerprint.result
?: BottomSheetMenuItemBuilderFingerprint.result
?: throw BottomSheetMenuItemBuilderFingerprint.exception
?: BottomSheetMenuItemBuilderFingerprint.resultOrThrow()
bottomSheetMenuItemBuilderResult.let {
it.mutableMethod.apply {
@ -65,7 +64,7 @@ object FeedFlyoutPanelPatch : BaseBytecodePatch(
/**
* Tablet
*/
ContextualMenuItemBuilderFingerprint.result?.let {
ContextualMenuItemBuilderFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.startIndex + 1
val targetInstruction = getInstruction<Instruction35c>(targetIndex)
@ -81,7 +80,7 @@ object FeedFlyoutPanelPatch : BaseBytecodePatch(
"$FLYOUT_PANEL_CLASS_DESCRIPTOR->hideFeedFlyoutPanel(Landroid/widget/TextView;Ljava/lang/CharSequence;)V"
)
}
} ?: throw ContextualMenuItemBuilderFingerprint.exception
}
/**
* 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.resourceid.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getReference
import app.revanced.util.getTargetIndex
import app.revanced.util.indexOfFirstInstruction
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
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.
*/
val videoQualityClass = VideoQualitySetterFingerprint.result?.mutableMethod?.definingClass
?: throw VideoQualitySetterFingerprint.exception
val videoQualityClass = VideoQualitySetterFingerprint.resultOrThrow().mutableMethod.definingClass
QualityMenuViewInflateFingerprint.result?.let {
QualityMenuViewInflateFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.endIndex
val insertRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
@ -82,7 +81,7 @@ object OldQualityLayoutPatch : BaseBytecodePatch(
""", ExternalLabel("show", getInstruction(jumpIndex))
)
} ?: throw PatchException("Failed to find onItemClick method")
} ?: throw QualityMenuViewInflateFingerprint.exception
}
/**
* 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.VIDEO_PATH
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.immutable.ImmutableField
@ -45,7 +45,7 @@ object OldSpeedLayoutPatch : BytecodePatch(
/**
* Input 'playbackRateBottomSheetClass' in FlyoutPanelPatch.
*/
PlaybackRateBottomSheetClassFingerprint.result?.let {
PlaybackRateBottomSheetClassFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
playbackRateBottomSheetClass = definingClass
playbackRateBottomSheetBuilderMethod =
@ -58,13 +58,13 @@ object OldSpeedLayoutPatch : BytecodePatch(
"sput-object p0, $INTEGRATIONS_CLASS_DESCRIPTOR->playbackRateBottomSheetClass:$playbackRateBottomSheetClass"
)
}
} ?: throw PlaybackRateBottomSheetClassFingerprint.exception
}
/**
* Create a static field in the patch
* Add a call the Playback Speed Bottom Sheet Fragment method
*/
CustomPlaybackSpeedIntegrationsFingerprint.result?.let {
CustomPlaybackSpeedIntegrationsFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
// Create a static field 'playbackRateBottomSheetClass' in FlyoutPanelPatch.
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")

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.FLYOUT_PANEL_CLASS_DESCRIPTOR
import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getStringInstructionIndex
import app.revanced.util.getTargetIndex
import app.revanced.util.getTargetIndexReversed
import app.revanced.util.indexOfFirstInstruction
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -41,15 +41,11 @@ object ChangeTogglePatch : BaseBytecodePatch(
) {
override fun execute(context: BytecodeContext) {
val additionalSettingsConfigResult = AdditionalSettingsConfigFingerprint.result
?: throw AdditionalSettingsConfigFingerprint.exception
val additionalSettingsConfigMethod = additionalSettingsConfigResult.mutableMethod
val additionalSettingsConfigMethod = AdditionalSettingsConfigFingerprint.resultOrThrow().mutableMethod
val methodToCall = additionalSettingsConfigMethod.definingClass + "->" + additionalSettingsConfigMethod.name + "()Z"
// Resolves fingerprints
val playbackLoopOnClickListenerResult = PlaybackLoopOnClickListenerFingerprint.result
?: throw PlaybackLoopOnClickListenerFingerprint.exception
val playbackLoopOnClickListenerResult = PlaybackLoopOnClickListenerFingerprint.resultOrThrow()
PlaybackLoopInitFingerprint.resolve(context, playbackLoopOnClickListenerResult.classDef)
arrayOf(
@ -79,7 +75,7 @@ object ChangeTogglePatch : BaseBytecodePatch(
fingerprint: MethodFingerprint,
methodToCall: String
) {
fingerprint.result?.let {
fingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val referenceIndex = indexOfFirstInstruction {
opcode == Opcode.INVOKE_VIRTUAL
@ -102,12 +98,11 @@ object ChangeTogglePatch : BaseBytecodePatch(
throw PatchException("Target reference'$methodToCall' was not found in ${this.javaClass.simpleName}.")
}
}
} ?: throw fingerprint.exception
}
}
private fun injectCinematicLightingMethod() {
val stableVolumeMethod = StableVolumeFingerprint.result?.mutableMethod
?: throw StableVolumeFingerprint.exception
val stableVolumeMethod = StableVolumeFingerprint.resultOrThrow().mutableMethod
val stringReferenceIndex = stableVolumeMethod.indexOfFirstInstruction {
opcode == Opcode.INVOKE_VIRTUAL
@ -118,7 +113,7 @@ object ChangeTogglePatch : BaseBytecodePatch(
val stringReference = stableVolumeMethod.getInstruction<ReferenceInstruction>(stringReferenceIndex).reference
CinematicLightingFingerprint.result?.let {
CinematicLightingFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val stringIndex = getStringInstructionIndex("menu_item_cinematic_lighting")
@ -163,6 +158,6 @@ object ChangeTogglePatch : BaseBytecodePatch(
""", 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.AutoNavToggle
import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getStringInstructionIndex
import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Suppress("unused")
@ -29,7 +29,7 @@ object AutoplayPreviewPatch : BaseBytecodePatch(
fingerprints = setOf(LayoutConstructorFingerprint)
) {
override fun execute(context: BytecodeContext) {
LayoutConstructorFingerprint.result?.let {
LayoutConstructorFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val dummyRegister =
getInstruction<OneRegisterInstruction>(getStringInstructionIndex("1.0x")).registerA
@ -44,7 +44,7 @@ object AutoplayPreviewPatch : BaseBytecodePatch(
""", ExternalLabel("hidden", getInstruction(jumpIndex))
)
}
} ?: throw LayoutConstructorFingerprint.exception
}
/**
* 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.resourceid.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getWalkerMethod
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Suppress("unused")
@ -26,7 +26,7 @@ object CompactControlsOverlayPatch : BaseBytecodePatch(
) {
override fun execute(context: BytecodeContext) {
YouTubeControlsOverlayFingerprint.result?.let {
YouTubeControlsOverlayFingerprint.resultOrThrow().let {
val walkerMethod = it.getWalkerMethod(context, it.scanResult.patternScanResult!!.startIndex)
walkerMethod.apply {
val insertIndex = implementation!!.instructions.size - 1
@ -40,7 +40,7 @@ object CompactControlsOverlayPatch : BaseBytecodePatch(
"""
)
}
} ?: throw YouTubeControlsOverlayFingerprint.exception
}
/**
* 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.resourceid.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
@Suppress("unused")
object EndScreenOverlayPatch : BaseBytecodePatch(
@ -25,7 +25,7 @@ object EndScreenOverlayPatch : BaseBytecodePatch(
fingerprints = setOf(EndScreenResultsParentFingerprint)
) {
override fun execute(context: BytecodeContext) {
EndScreenResultsParentFingerprint.result?.let {
EndScreenResultsParentFingerprint.resultOrThrow().let {
it.mutableClass.methods.find { method -> method.parameters == listOf("I", "Z", "I") }
?.apply {
addInstructionsWithLabels(
@ -37,7 +37,7 @@ object EndScreenOverlayPatch : BaseBytecodePatch(
""", ExternalLabel("show", getInstruction(0))
)
} ?: throw PatchException("Could not find targetMethod")
} ?: throw EndScreenResultsParentFingerprint.exception
}
/**
* 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.FULLSCREEN_CLASS_DESCRIPTOR
import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getStringInstructionIndex
import app.revanced.util.getTargetIndex
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -35,7 +35,7 @@ object ForceFullscreenPatch : BaseBytecodePatch(
/**
* Process that hooks Activity for using {Activity.setRequestedOrientation}.
*/
ClientSettingEndpointFingerprint.result?.let {
ClientSettingEndpointFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val getActivityIndex = getStringInstructionIndex("watch") + 2
val getActivityReference =
@ -66,13 +66,13 @@ object ForceFullscreenPatch : BaseBytecodePatch(
"""
)
}
} ?: throw ClientSettingEndpointFingerprint.exception
}
/**
* Don't rotate the screen in vertical video.
* Add an instruction to check the vertical video.
*/
VideoPortraitParentFingerprint.result?.let {
VideoPortraitParentFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val stringIndex =
getStringInstructionIndex("Acquiring NetLatencyActionLogger failed. taskId=")
@ -90,7 +90,7 @@ object ForceFullscreenPatch : BaseBytecodePatch(
)
} ?: throw PatchException("Could not find targetMethod")
}
} ?: throw VideoPortraitParentFingerprint.exception
}
/**
* 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.resourceid.SharedResourceIdPatch.FullScreenEngagementPanel
import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getTargetIndex
import app.revanced.util.getTargetIndexWithMethodReferenceName
import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -36,7 +36,7 @@ object FullscreenPanelsPatch : BaseBytecodePatch(
) {
override fun execute(context: BytecodeContext) {
FullscreenEngagementPanelFingerprint.result?.let {
FullscreenEngagementPanelFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val literalIndex = getWideLiteralInstructionIndex(FullScreenEngagementPanel)
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"
)
}
} ?: throw FullscreenEngagementPanelFingerprint.exception
}
LayoutConstructorFingerprint.result?.let {
LayoutConstructorFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val dummyIndex = getWideLiteralInstructionIndex(159962)
val dummyRegister = getInstruction<OneRegisterInstruction>(dummyIndex).registerA
@ -63,7 +63,7 @@ object FullscreenPanelsPatch : BaseBytecodePatch(
""", ExternalLabel("hidden", getInstruction(addViewIndex + 1))
)
}
} ?: throw LayoutConstructorFingerprint.exception
}
/**
* 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.FULLSCREEN_CLASS_DESCRIPTOR
import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getStringInstructionIndex
import app.revanced.util.getTargetIndex
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -36,28 +36,28 @@ object LandScapeModePatch : BaseBytecodePatch(
/**
* Disable landscape mode
*/
OrientationParentFingerprint.result?.classDef?.let { classDef ->
OrientationParentFingerprint.resultOrThrow().classDef.let { classDef ->
arrayOf(
OrientationPrimaryFingerprint,
OrientationSecondaryFingerprint
).forEach { fingerprint ->
fingerprint.resolve(context, classDef)
fingerprint.result?.let {
fingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val index = it.scanResult.patternScanResult!!.endIndex
val register = getInstruction<OneRegisterInstruction>(index).registerA
addInstructions(
index + 1, """
invoke-static {v$register}, $FULLSCREEN_CLASS_DESCRIPTOR->disableLandScapeMode(Z)Z
move-result v$register
"""
invoke-static {v$register}, $FULLSCREEN_CLASS_DESCRIPTOR->disableLandScapeMode(Z)Z
move-result v$register
"""
)
}
} ?: throw fingerprint.exception
}
}
} ?: throw OrientationParentFingerprint.exception
}
/**
* Keep landscape mode
@ -75,7 +75,7 @@ object LandScapeModePatch : BaseBytecodePatch(
)
}
BroadcastReceiverFingerprint.result?.let { result ->
BroadcastReceiverFingerprint.resultOrThrow().let { result ->
result.mutableMethod.apply {
val stringIndex = getStringInstructionIndex("android.intent.action.SCREEN_ON")
val insertIndex = getTargetIndex(stringIndex, Opcode.IF_EQZ) + 1
@ -85,7 +85,7 @@ object LandScapeModePatch : BaseBytecodePatch(
"invoke-static {}, $FULLSCREEN_CLASS_DESCRIPTOR->setScreenStatus()V"
)
}
} ?: throw BroadcastReceiverFingerprint.exception
}
SettingsPatch.addPreference(
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.resourceid.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
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.ReferenceInstruction
@ -36,10 +36,10 @@ object AccountMenuPatch : BaseBytecodePatch(
) {
override fun execute(context: BytecodeContext) {
AccountListParentFingerprint.result?.let { parentResult ->
AccountListParentFingerprint.resultOrThrow().let { parentResult ->
AccountListFingerprint.resolve(context, parentResult.classDef)
AccountListFingerprint.result?.let {
AccountListFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.startIndex + 3
val targetInstruction = getInstruction<FiveRegisterInstruction>(targetIndex)
@ -50,14 +50,14 @@ object AccountMenuPatch : BaseBytecodePatch(
"$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)
SetViewGroupMarginFingerprint.resolve(context, parentResult.classDef)
AccountMenuFingerprint.result?.let {
AccountMenuFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.startIndex + 2
val targetInstruction = getInstruction<FiveRegisterInstruction>(targetIndex)
@ -68,23 +68,23 @@ object AccountMenuPatch : BaseBytecodePatch(
"$GENERAL_CLASS_DESCRIPTOR->hideAccountMenu(Landroid/view/View;Ljava/lang/CharSequence;)V"
)
}
} ?: throw AccountMenuFingerprint.exception
}
SetViewGroupMarginFingerprint.result?.let {
SetViewGroupMarginFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val setViewGroupMarginIndex = it.scanResult.patternScanResult!!.startIndex
val setViewGroupMarginReference =
getInstruction<ReferenceInstruction>(setViewGroupMarginIndex).reference
AccountMenuPatchFingerprint.result?.mutableMethod?.addInstructions(
AccountMenuPatchFingerprint.resultOrThrow().mutableMethod.addInstructions(
0, """
const/4 v0, 0x0
invoke-static {p0, v0, v0}, $setViewGroupMarginReference
"""
) ?: throw AccountMenuPatchFingerprint.exception
)
}
} ?: throw SetViewGroupMarginFingerprint.exception
} ?: throw AccountMenuParentFingerprint.exception
}
}
/**
* 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.GENERAL_CLASS_DESCRIPTOR
import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
@Suppress("unused")
object PlayerPopupPanelsPatch : BaseBytecodePatch(
@ -21,7 +21,7 @@ object PlayerPopupPanelsPatch : BaseBytecodePatch(
) {
override fun execute(context: BytecodeContext) {
EngagementPanelControllerFingerprint.result?.let {
EngagementPanelControllerFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
addInstructionsWithLabels(
0, """
@ -35,7 +35,7 @@ object PlayerPopupPanelsPatch : BaseBytecodePatch(
""", ExternalLabel("shown", getInstruction(0))
)
}
} ?: throw EngagementPanelControllerFingerprint.exception
}
/**
* 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.GENERAL_CLASS_DESCRIPTOR
import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
@Suppress("unused")
object CastButtonPatch : BaseBytecodePatch(
@ -18,7 +18,7 @@ object CastButtonPatch : BaseBytecodePatch(
fingerprints = setOf(CastButtonFingerprint)
) {
override fun execute(context: BytecodeContext) {
CastButtonFingerprint.result?.let {
CastButtonFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
addInstructions(
0, """
@ -27,7 +27,7 @@ object CastButtonPatch : BaseBytecodePatch(
"""
)
}
} ?: throw CastButtonFingerprint.exception
}
/**
* 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.resourceid.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
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.TwoRegisterInstruction
@ -71,7 +71,7 @@ object CategoryBarPatch : BaseBytecodePatch(
hookRegisterOffset: Int = 0,
instructions: (Int) -> String
) =
result?.let {
resultOrThrow().let {
it.mutableMethod.apply {
val endIndex = it.scanResult.patternScanResult!!.endIndex
@ -81,5 +81,5 @@ object CategoryBarPatch : BaseBytecodePatch(
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.resourceid.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Suppress("unused")
@ -32,7 +32,7 @@ object ChannelListSubMenuPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) {
LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)
ChannelListSubMenuFingerprint.result?.let {
ChannelListSubMenuFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val endIndex = it.scanResult.patternScanResult!!.endIndex
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"
)
}
} ?: throw ChannelListSubMenuFingerprint.exception
}
/**
* 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.TabsBarTextTabView
import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Suppress("unused")
@ -32,7 +32,7 @@ object ChannelProfileComponentsPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) {
DefaultsTabsBarFingerprint.result?.let {
DefaultsTabsBarFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val viewIndex = getWideLiteralInstructionIndex(TabsBarTextTabView) + 2
val viewRegister = getInstruction<OneRegisterInstruction>(viewIndex).registerA
@ -42,7 +42,7 @@ object ChannelProfileComponentsPatch : BaseBytecodePatch(
"sput-object v$viewRegister, $FILTER_CLASS_DESCRIPTOR->channelTabView:Landroid/view/View;"
)
}
} ?: throw DefaultsTabsBarFingerprint.exception
}
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.resourceid.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
@Suppress("unused")
@ -25,7 +25,7 @@ object CrowdfundingBoxPatch : BaseBytecodePatch(
) {
override fun execute(context: BytecodeContext) {
CrowdfundingBoxFingerprint.result?.let {
CrowdfundingBoxFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.endIndex
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"
)
}
} ?: throw CrowdfundingBoxFingerprint.exception
}
/**
* 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.recyclerview.BottomSheetRecyclerViewPatch
import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getTargetIndexWithMethodReferenceName
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
@Suppress("unused")
@ -33,7 +33,7 @@ object DescriptionComponentsPatch : BaseBytecodePatch(
override fun execute(context: BytecodeContext) {
if (SettingsPatch.upward1902) {
TextViewComponentFingerprint.result?.let {
TextViewComponentFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val insertIndex = getTargetIndexWithMethodReferenceName("setTextIsSelectable")
val insertInstruction = getInstruction<FiveRegisterInstruction>(insertIndex)
@ -44,7 +44,7 @@ object DescriptionComponentsPatch : BaseBytecodePatch(
"$GENERAL_CLASS_DESCRIPTOR->disableDescriptionInteraction(Landroid/widget/TextView;Z)V"
)
}
} ?: throw TextViewComponentFingerprint.exception
}
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