-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Merge RVX v4.12.1-dev.1 (#791)
- Loading branch information
Showing
76 changed files
with
1,426 additions
and
748 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
src/main/kotlin/app/revanced/patches/music/misc/share/ShareSheetPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
) | ||
|
||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
.../app/revanced/patches/music/misc/share/fingerprints/BottomSheetRecyclerViewFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
136 changes: 136 additions & 0 deletions
136
src/main/kotlin/app/revanced/patches/youtube/general/downloads/DownloadActionsPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
...essibilityOfflineButtonSyncFingerprint.kt → ...essibilityOfflineButtonSyncFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } | ||
) | ||
) |
Oops, something went wrong.