Skip to content

Commit

Permalink
feat: Merge RVX v4.12.1-dev.1 (#791)
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco146 authored Aug 7, 2024
2 parents 9417f19 + cacfd11 commit de1ddcf
Show file tree
Hide file tree
Showing 76 changed files with 1,426 additions and 748 deletions.
45 changes: 26 additions & 19 deletions api/revanced-patches.api
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,12 @@ public final class app/revanced/patches/music/misc/debugging/DebuggingPatch : ap
public fun execute (Lapp/revanced/patcher/data/ResourceContext;)V
}

public final class app/revanced/patches/music/misc/share/ShareSheetPatch : app/revanced/util/patch/BaseBytecodePatch {
public static final field INSTANCE Lapp/revanced/patches/music/misc/share/ShareSheetPatch;
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
}

public final class app/revanced/patches/music/misc/splash/CairoSplashAnimationPatch : app/revanced/patcher/patch/BytecodePatch {
public static final field INSTANCE Lapp/revanced/patches/music/misc/splash/CairoSplashAnimationPatch;
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
Expand Down Expand Up @@ -337,6 +343,7 @@ public final class app/revanced/patches/music/utils/resourceid/SharedResourceIdP
public fun execute (Lapp/revanced/patcher/data/ResourceContext;)V
public final fun getAccountSwitcherAccessibility ()J
public final fun getAudioVideoSwitchToggle ()J
public final fun getBottomSheetRecyclerView ()J
public final fun getButtonContainer ()J
public final fun getButtonIconPaddingMedium ()J
public final fun getChipCloud ()J
Expand Down Expand Up @@ -378,6 +385,7 @@ public final class app/revanced/patches/music/utils/resourceid/SharedResourceIdP
public final fun getVarispeedUnavailableTitle ()J
public final fun setAccountSwitcherAccessibility (J)V
public final fun setAudioVideoSwitchToggle (J)V
public final fun setBottomSheetRecyclerView (J)V
public final fun setButtonContainer (J)V
public final fun setButtonIconPaddingMedium (J)V
public final fun setChipCloud (J)V
Expand Down Expand Up @@ -984,6 +992,12 @@ public final class app/revanced/patches/youtube/general/dialog/ViewerDiscretionD
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
}

public final class app/revanced/patches/youtube/general/downloads/DownloadActionsPatch : app/revanced/util/patch/BaseBytecodePatch {
public static final field INSTANCE Lapp/revanced/patches/youtube/general/downloads/DownloadActionsPatch;
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
}

public final class app/revanced/patches/youtube/general/layoutswitch/LayoutSwitchPatch : app/revanced/util/patch/BaseBytecodePatch {
public static final field INSTANCE Lapp/revanced/patches/youtube/general/layoutswitch/LayoutSwitchPatch;
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
Expand Down Expand Up @@ -1137,25 +1151,6 @@ public final class app/revanced/patches/youtube/misc/debugging/DebuggingPatch :
public fun execute (Lapp/revanced/patcher/data/ResourceContext;)V
}

public final class app/revanced/patches/youtube/misc/downloadactions/HookDownloadActionsPatch : app/revanced/util/patch/BaseBytecodePatch {
public static final field INSTANCE Lapp/revanced/patches/youtube/misc/downloadactions/HookDownloadActionsPatch;
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
}

public final class app/revanced/patches/youtube/misc/downloadactions/fingerprints/AccessibilityOfflineButtonSyncFingerprint : app/revanced/util/fingerprint/LiteralValueFingerprint {
public static final field INSTANCE Lapp/revanced/patches/youtube/misc/downloadactions/fingerprints/AccessibilityOfflineButtonSyncFingerprint;
}

public final class app/revanced/patches/youtube/misc/downloadactions/fingerprints/DownloadPlaylistButtonOnClickFingerprint : app/revanced/patcher/fingerprint/MethodFingerprint {
public static final field INSTANCE Lapp/revanced/patches/youtube/misc/downloadactions/fingerprints/DownloadPlaylistButtonOnClickFingerprint;
public final fun getPLAYLIST_ON_CLICK_INITIALIZE_PAREMETER ()Ljava/util/List;
}

public final class app/revanced/patches/youtube/misc/downloadactions/fingerprints/SetPlaylistDownloadButtonVisibilityFingerprint : app/revanced/patcher/fingerprint/MethodFingerprint {
public static final field INSTANCE Lapp/revanced/patches/youtube/misc/downloadactions/fingerprints/SetPlaylistDownloadButtonVisibilityFingerprint;
}

public final class app/revanced/patches/youtube/misc/externalbrowser/OpenLinksExternallyBytecodePatch : app/revanced/patches/shared/transformation/BaseTransformInstructionsPatch {
public static final field INSTANCE Lapp/revanced/patches/youtube/misc/externalbrowser/OpenLinksExternallyBytecodePatch;
public synthetic fun filterMap (Lcom/android/tools/smali/dexlib2/iface/ClassDef;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;I)Ljava/lang/Object;
Expand Down Expand Up @@ -1506,6 +1501,12 @@ public final class app/revanced/patches/youtube/utils/navigation/fingerprints/Se
public static final field INSTANCE Lapp/revanced/patches/youtube/utils/navigation/fingerprints/SettingsActivityOnBackPressedFingerprint;
}

public final class app/revanced/patches/youtube/utils/pip/PiPStateHookPatch : app/revanced/patcher/patch/BytecodePatch {
public static final field INSTANCE Lapp/revanced/patches/youtube/utils/pip/PiPStateHookPatch;
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
}

public final class app/revanced/patches/youtube/utils/playercontrols/PlayerControlsPatch : app/revanced/patcher/patch/BytecodePatch {
public static final field INSTANCE Lapp/revanced/patches/youtube/utils/playercontrols/PlayerControlsPatch;
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
Expand Down Expand Up @@ -1814,6 +1815,12 @@ public final class app/revanced/patches/youtube/utils/toolbar/ToolBarHookPatch :
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
}

public final class app/revanced/patches/youtube/utils/trackingurlhook/TrackingUrlHookPatch : app/revanced/patcher/patch/BytecodePatch {
public static final field INSTANCE Lapp/revanced/patches/youtube/utils/trackingurlhook/TrackingUrlHookPatch;
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
}

public final class app/revanced/patches/youtube/video/information/VideoInformationPatch : app/revanced/patcher/patch/BytecodePatch {
public static final field INSTANCE Lapp/revanced/patches/youtube/video/information/VideoInformationPatch;
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package app.revanced.patches.music.misc.share

import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patches.music.misc.share.fingerprints.BottomSheetRecyclerViewFingerprint
import app.revanced.patches.music.utils.compatibility.Constants.COMPATIBLE_PACKAGE
import app.revanced.patches.music.utils.integrations.Constants.COMPONENTS_PATH
import app.revanced.patches.music.utils.integrations.Constants.MISC_PATH
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.BottomSheetRecyclerView
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.getTargetIndexOrThrow
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

@Suppress("unused")
object ShareSheetPatch : BaseBytecodePatch(
name = "Change share sheet",
description = "Add option to change from in-app share sheet to system share sheet.",
dependencies = setOf(
LithoFilterPatch::class,
SettingsPatch::class,
SharedResourceIdPatch::class
),
compatiblePackages = COMPATIBLE_PACKAGE,
fingerprints = setOf(BottomSheetRecyclerViewFingerprint)
) {
private const val INTEGRATIONS_CLASS_DESCRIPTOR =
"$MISC_PATH/ShareSheetPatch;"

private const val FILTER_CLASS_DESCRIPTOR =
"$COMPONENTS_PATH/ShareSheetMenuFilter;"

override fun execute(context: BytecodeContext) {

BottomSheetRecyclerViewFingerprint.resultOrThrow().mutableMethod.apply {
val constIndex = getWideLiteralInstructionIndex(BottomSheetRecyclerView)
val targetIndex = getTargetIndexOrThrow(constIndex, Opcode.CHECK_CAST)
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA

addInstruction(
targetIndex + 1,
"invoke-static {v$targetRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->onShareSheetMenuCreate(Landroid/support/v7/widget/RecyclerView;)V"
)
}

LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)

SettingsPatch.addSwitchPreference(
CategoryType.MISC,
"revanced_change_share_sheet",
"false"
)

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package app.revanced.patches.music.misc.share.fingerprints

import app.revanced.patcher.extensions.or
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.BottomSheetRecyclerView
import app.revanced.util.fingerprint.LiteralValueFingerprint
import com.android.tools.smali.dexlib2.AccessFlags

internal object BottomSheetRecyclerViewFingerprint : LiteralValueFingerprint(
returnType = "Lj${'$'}/util/Optional;",
accessFlags = AccessFlags.PROTECTED or AccessFlags.FINAL,
parameters = emptyList(),
literalSupplier = { BottomSheetRecyclerView }
)
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import app.revanced.util.literalInstructionBooleanHook
"com.google.android.apps.youtube.music",
[
"7.08.54",
"7.12.51",
"7.13.52",
]
)
]
Expand All @@ -43,7 +43,8 @@ object CairoSplashAnimationPatch : BytecodePatch(
"false"
)

} ?: throw PatchException("WARNING: This patch is not supported in this version. Use YouTube Music 7.08.54 or later.")
}
?: throw PatchException("WARNING: This patch is not supported in this version. Use YouTube Music 7.08.54 or later.")

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ object Constants {
"6.33.52", // This is the latest version with the legacy code of YouTube Music.
"6.42.55", // This is the latest version that supports Android 7.0
"6.51.53", // This is the latest version of YouTube Music 6.xx.xx
"7.11.51", // This was the latest version that was supported by the previous patch.
"7.12.51", // This is the latest version supported by the RVX patch.
"7.12.52", // This was the latest version that was supported by the previous patch.
"7.13.52", // This is the latest version supported by the RVX patch.
)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import app.revanced.patches.shared.mapping.ResourceType.STYLE
object SharedResourceIdPatch : ResourcePatch() {
var AccountSwitcherAccessibility = -1L
var AudioVideoSwitchToggle = -1L
var BottomSheetRecyclerView = -1L
var ButtonContainer = -1L
var ButtonIconPaddingMedium = -1L
var ChipCloud = -1L
Expand Down Expand Up @@ -61,6 +62,7 @@ object SharedResourceIdPatch : ResourcePatch() {

AccountSwitcherAccessibility = getId(STRING, "account_switcher_accessibility_label")
AudioVideoSwitchToggle = getId(ID, "audio_video_switch_toggle")
BottomSheetRecyclerView = getId(LAYOUT, "bottom_sheet_recycler_view")
ButtonContainer = getId(ID, "button_container")
ButtonIconPaddingMedium = getId(DIMEN, "button_icon_padding_medium")
ChipCloud = getId(LAYOUT, "chip_cloud")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
package app.revanced.patches.youtube.general.downloads

import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstructions
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.youtube.general.downloads.fingerprints.AccessibilityOfflineButtonSyncFingerprint
import app.revanced.patches.youtube.general.downloads.fingerprints.DownloadPlaylistButtonOnClickFingerprint
import app.revanced.patches.youtube.general.downloads.fingerprints.DownloadPlaylistButtonOnClickFingerprint.indexOfPlaylistDownloadActionInvokeInstruction
import app.revanced.patches.youtube.general.downloads.fingerprints.OfflineVideoEndpointFingerprint
import app.revanced.patches.youtube.general.downloads.fingerprints.SetPlaylistDownloadButtonVisibilityFingerprint
import app.revanced.patches.youtube.utils.compatibility.Constants
import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL_PATH
import app.revanced.patches.youtube.utils.pip.PiPStateHookPatch
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.alsoResolve
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionOrThrow
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
import com.android.tools.smali.dexlib2.iface.reference.MethodReference

@Suppress("unused")
object DownloadActionsPatch : BaseBytecodePatch(
name = "Hook download actions",
description = "Adds support to download videos with an external downloader app using the in-app download button.",
dependencies = setOf(
PiPStateHookPatch::class,
SharedResourceIdPatch::class,
SettingsPatch::class
),
compatiblePackages = Constants.COMPATIBLE_PACKAGE,
fingerprints = setOf(
AccessibilityOfflineButtonSyncFingerprint,
DownloadPlaylistButtonOnClickFingerprint,
OfflineVideoEndpointFingerprint,
)
) {
private const val INTEGRATIONS_CLASS_DESCRIPTOR =
"$GENERAL_PATH/DownloadActionsPatch;"

override fun execute(context: BytecodeContext) {

// region patch for hook download actions (video action bar and flyout panel)

OfflineVideoEndpointFingerprint.resultOrThrow().mutableMethod.apply {
addInstructionsWithLabels(
0, """
invoke-static/range {p3 .. p3}, $INTEGRATIONS_CLASS_DESCRIPTOR->inAppVideoDownloadButtonOnClick(Ljava/lang/String;)Z
move-result v0
if-eqz v0, :show_native_downloader
return-void
""", ExternalLabel("show_native_downloader", getInstruction(0))
)
}

// endregion

// region patch for hook download actions (playlist)

val onClickListenerClass =
DownloadPlaylistButtonOnClickFingerprint.resultOrThrow().mutableMethod.let {
val playlistDownloadActionInvokeIndex =
indexOfPlaylistDownloadActionInvokeInstruction(it)

it.getInstructions().subList(
playlistDownloadActionInvokeIndex - 10,
playlistDownloadActionInvokeIndex,
).find { instruction ->
instruction.opcode == Opcode.INVOKE_VIRTUAL_RANGE
&& instruction.getReference<MethodReference>()?.parameterTypes?.first() == "Ljava/lang/String;"
}?.getReference<MethodReference>()?.returnType
?: throw PatchException("Could not find onClickListenerClass")
}

context.findClass(onClickListenerClass)
?.mutableClass
?.methods
?.first { method -> method.name == "onClick" }?.apply {
val insertIndex = indexOfFirstInstructionOrThrow {
opcode == Opcode.INVOKE_STATIC
&& getReference<MethodReference>()?.name == "isEmpty"
}
val insertRegister = getInstruction<FiveRegisterInstruction>(insertIndex).registerC

addInstructions(
insertIndex, """
invoke-static {v$insertRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->inAppPlaylistDownloadButtonOnClick(Ljava/lang/String;)Ljava/lang/String;
move-result-object v$insertRegister
"""
)
} ?: throw PatchException("Could not find class $onClickListenerClass")

// endregion

// region patch for show the playlist download button

SetPlaylistDownloadButtonVisibilityFingerprint
.alsoResolve(context, AccessibilityOfflineButtonSyncFingerprint).let {
it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.startIndex + 2
val insertRegister =
getInstruction<OneRegisterInstruction>(insertIndex).registerA

addInstructions(
insertIndex, """
invoke-static {}, $INTEGRATIONS_CLASS_DESCRIPTOR->overridePlaylistDownloadButtonVisibility()Z
move-result v$insertRegister
"""
)
}
}

// endregion

/**
* Add settings
*/
SettingsPatch.addPreference(
arrayOf(
"PREFERENCE_SCREEN: GENERAL",
"PREFERENCE_CATEGORY: GENERAL_EXPERIMENTAL_FLAGS",
"SETTINGS: HOOK_DOWNLOAD_ACTIONS"
)
)

SettingsPatch.updatePatchStatus(this)
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package app.revanced.patches.youtube.misc.downloadactions.fingerprints
package app.revanced.patches.youtube.general.downloads.fingerprints

import app.revanced.patcher.extensions.or
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.AccessibilityOfflineButtonSync
import app.revanced.util.fingerprint.LiteralValueFingerprint
import com.android.tools.smali.dexlib2.AccessFlags

object AccessibilityOfflineButtonSyncFingerprint : LiteralValueFingerprint(
internal object AccessibilityOfflineButtonSyncFingerprint : LiteralValueFingerprint(
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
returnType = "V",
literalSupplier = { AccessibilityOfflineButtonSync }
)
)
Loading

0 comments on commit de1ddcf

Please sign in to comment.