fix: Revert previous release

The previous release depends on a version of ReVanced Patcher which prevents usage of resource patches on lower Android versions. To solve this issue temporarily, until a fix is present, the previous release is reverted.
This commit is contained in:
oSumAtrIX
2023-08-27 04:37:21 +02:00
parent ce2e46a7cb
commit 3938f2f1b3
496 changed files with 2551 additions and 2425 deletions
@@ -3,6 +3,6 @@ package app.revanced.patches.youtube.interaction.copyvideourl.annotation
import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package
@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35", "18.29.38", "18.32.39"))])
@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))])
@Target(AnnotationTarget.CLASS)
internal annotation class CopyVideoUrlCompatibility
@@ -4,6 +4,8 @@ import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.interaction.copyvideourl.annotation.CopyVideoUrlCompatibility
@@ -29,12 +31,14 @@ class CopyVideoUrlBytecodePatch : BytecodePatch() {
)
}
override fun execute(context: BytecodeContext) {
override fun execute(context: BytecodeContext): PatchResult {
// Initialize buttons and inject visibility control
BUTTONS_DESCRIPTORS.forEach { descriptor ->
PlayerControlsBytecodePatch.initializeControl("$descriptor->initializeButton(Landroid/view/View;)V")
PlayerControlsBytecodePatch.injectVisibilityCheckCall("$descriptor->changeVisibility(Z)V")
}
return PatchResultSuccess()
}
}
@@ -1,6 +1,8 @@
package app.revanced.patches.youtube.interaction.copyvideourl.resource.patch
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen
@@ -14,7 +16,7 @@ import app.revanced.util.resources.ResourceUtils.mergeStrings
@DependsOn([BottomControlsResourcePatch::class, SettingsPatch::class])
class CopyVideoUrlResourcePatch : ResourcePatch {
override fun execute(context: ResourceContext) {
override fun execute(context: ResourceContext): PatchResult {
SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences(
PreferenceScreen(
"revanced_copy_video_url_preference_screen",
@@ -47,5 +49,7 @@ class CopyVideoUrlResourcePatch : ResourcePatch {
context.mergeStrings("copyvideourl/host/values/strings.xml")
BottomControlsResourcePatch.addControls("copyvideourl/host/layout/${BottomControlsResourcePatch.TARGET_RESOURCE_NAME}")
return PatchResultSuccess()
}
}
@@ -3,7 +3,7 @@ package app.revanced.patches.youtube.interaction.downloads.annotation
import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package
@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35", "18.29.38", "18.32.39"))])
@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))])
@Target(AnnotationTarget.CLASS)
internal annotation class ExternalDownloadsCompatibility
@@ -4,6 +4,8 @@ import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.interaction.downloads.annotation.ExternalDownloadsCompatibility
@@ -21,7 +23,7 @@ class ExternalDownloadsBytecodePatch : BytecodePatch() {
const val BUTTON_DESCRIPTOR = "Lapp/revanced/integrations/videoplayer/ExternalDownloadButton;"
}
override fun execute(context: BytecodeContext) {
override fun execute(context: BytecodeContext): PatchResult {
/*
initialize the control
*/
@@ -35,5 +37,7 @@ class ExternalDownloadsBytecodePatch : BytecodePatch() {
PlayerControlsBytecodePatch.injectVisibilityCheckCall(
"$BUTTON_DESCRIPTOR->changeVisibility(Z)V")
return PatchResultSuccess()
}
}
@@ -1,6 +1,8 @@
package app.revanced.patches.youtube.interaction.downloads.resource.patch
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.settings.preference.impl.*
@@ -13,7 +15,7 @@ import app.revanced.util.resources.ResourceUtils.mergeStrings
@DependsOn([BottomControlsResourcePatch::class, SettingsPatch::class])
class ExternalDownloadsResourcePatch : ResourcePatch {
override fun execute(context: ResourceContext) {
override fun execute(context: ResourceContext): PatchResult {
SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences(
PreferenceScreen(
"revanced_external_downloader_preference_screen",
@@ -28,7 +30,7 @@ class ExternalDownloadsResourcePatch : ResourcePatch {
TextPreference(
"revanced_external_downloader_name",
StringResource("revanced_external_downloader_name_title", "Downloader package name"),
StringResource("revanced_external_downloader_name_summary", "Package name of your installed external downloader app, such as NewPipe or Seal"),
StringResource("revanced_external_downloader_name_summary", "Package name of your installed external downloader app, such as NewPipe or PowerTube"),
InputType.TEXT
)
),
@@ -45,5 +47,7 @@ class ExternalDownloadsResourcePatch : ResourcePatch {
// Add download button node
BottomControlsResourcePatch.addControls("downloads/host/layout/${BottomControlsResourcePatch.TARGET_RESOURCE_NAME}")
return PatchResultSuccess()
}
}
}
@@ -3,7 +3,7 @@ package app.revanced.patches.youtube.interaction.seekbar.annotation
import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package
@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35", "18.29.38", "18.32.39"))])
@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))])
@Target(AnnotationTarget.CLASS)
internal annotation class SeekbarTappingCompatibility
@@ -0,0 +1,12 @@
package app.revanced.patches.youtube.interaction.seekbar.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patches.youtube.interaction.seekbar.patch.EnableSeekbarTappingResourcePatch
import app.revanced.util.patch.LiteralValueFingerprint
import org.jf.dexlib2.AccessFlags
object AccessibilityPlayerProgressTimeFingerprint : LiteralValueFingerprint(
returnType = "L",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
literal = EnableSeekbarTappingResourcePatch.accessibilityPlayerProgressTime
)
@@ -1,32 +0,0 @@
package app.revanced.patches.youtube.interaction.seekbar.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
@FuzzyPatternScanMethod(3)
object OnTouchEventHandlerFingerprint : MethodFingerprint(
returnType = "Z",
accessFlags = AccessFlags.PUBLIC or AccessFlags.PUBLIC,
parameters = listOf("L"),
opcodes = listOf(
Opcode.INVOKE_VIRTUAL, // oMethodReference
Opcode.RETURN,
Opcode.IGET_OBJECT,
Opcode.IGET_BOOLEAN,
Opcode.IF_EQZ,
Opcode.INVOKE_VIRTUAL,
Opcode.RETURN,
Opcode.INT_TO_FLOAT,
Opcode.INT_TO_FLOAT,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT,
Opcode.IF_NEZ,
Opcode.RETURN,
Opcode.INVOKE_VIRTUAL,
Opcode.INVOKE_VIRTUAL, // pMethodReference
),
customFingerprint = { methodDef, _ -> methodDef.name == "onTouchEvent" }
)
@@ -2,9 +2,9 @@ package app.revanced.patches.youtube.interaction.seekbar.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.NarrowLiteralInstruction
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction
object SeekbarTappingFingerprint : MethodFingerprint(
@@ -1,25 +1,25 @@
package app.revanced.patches.youtube.interaction.seekbar.patch
import app.revanced.extensions.exception
import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.youtube.interaction.seekbar.annotation.SeekbarTappingCompatibility
import app.revanced.patches.youtube.interaction.seekbar.fingerprints.OnTouchEventHandlerFingerprint
import app.revanced.patches.youtube.interaction.seekbar.fingerprints.AccessibilityPlayerProgressTimeFingerprint
import app.revanced.patches.youtube.interaction.seekbar.fingerprints.SeekbarTappingFingerprint
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.Method
import com.android.tools.smali.dexlib2.iface.instruction.NarrowLiteralInstruction
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.Method
import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction
import org.jf.dexlib2.iface.instruction.formats.Instruction35c
@Patch
@DependsOn([IntegrationsPatch::class, EnableSeekbarTappingResourcePatch::class])
@@ -27,23 +27,37 @@ import com.android.tools.smali.dexlib2.iface.reference.MethodReference
@Description("Enables tap-to-seek on the seekbar of the video player.")
@SeekbarTappingCompatibility
class EnableSeekbarTappingPatch : BytecodePatch(
listOf(OnTouchEventHandlerFingerprint, SeekbarTappingFingerprint)
listOf(AccessibilityPlayerProgressTimeFingerprint, SeekbarTappingFingerprint)
) {
override fun execute(context: BytecodeContext) {
override fun execute(context: BytecodeContext): PatchResult {
// Find the required methods to tap the seekbar.
val seekbarTappingMethods = OnTouchEventHandlerFingerprint.result?.let {
val patternScanResult = it.scanResult.patternScanResult!!
val seekbarTappingMethods =
AccessibilityPlayerProgressTimeFingerprint.result?.classDef?.methods?.let { methods ->
buildMap {
// find the methods which tap the seekbar
methods.forEach { method ->
if (method.implementation == null) return@forEach
fun getReference(index: Int) = it.mutableMethod.getInstruction<ReferenceInstruction>(index)
.reference as MethodReference
val instructions = method.implementation!!.instructions
buildMap {
put("O", getReference(patternScanResult.endIndex))
put("N", getReference(patternScanResult.startIndex))
// The method has more than 7 instructions.
if (instructions.count() < 7) return@forEach
// The 7th instruction has the opcode CONST_4.
val instruction = instructions.elementAt(6)
if (instruction.opcode != Opcode.CONST_4) return@forEach
// the literal for this instruction has to be either 1 or 2.
val literal = (instruction as NarrowLiteralInstruction).narrowLiteral
// Based on the literal, determine which method is which.
if (literal == 1) this["P"] = method
if (literal == 2) this["O"] = method
}
}
}
}
seekbarTappingMethods ?: throw OnTouchEventHandlerFingerprint.exception
seekbarTappingMethods ?: return AccessibilityPlayerProgressTimeFingerprint.toErrorResult()
SeekbarTappingFingerprint.result?.let {
val insertIndex = it.scanResult.patternScanResult!!.endIndex - 1
@@ -54,11 +68,11 @@ class EnableSeekbarTappingPatch : BytecodePatch(
val freeRegister = 0
val xAxisRegister = 2
val pMethod = seekbarTappingMethods["P"]!!
val oMethod = seekbarTappingMethods["O"]!!
val nMethod = seekbarTappingMethods["N"]!!
fun MethodReference.toInvokeInstructionString() =
"invoke-virtual { v$thisInstanceRegister, v$xAxisRegister }, $this"
fun Method.toInvokeInstructionString() =
"invoke-virtual { v$thisInstanceRegister, v$xAxisRegister }, $definingClass->$name(I)V"
addInstructionsWithLabels(
insertIndex,
@@ -67,11 +81,13 @@ class EnableSeekbarTappingPatch : BytecodePatch(
move-result v$freeRegister
if-eqz v$freeRegister, :disabled
${oMethod.toInvokeInstructionString()}
${nMethod.toInvokeInstructionString()}
${pMethod.toInvokeInstructionString()}
""",
ExternalLabel("disabled", getInstruction(insertIndex))
)
}
} ?: throw SeekbarTappingFingerprint.exception
} ?: return SeekbarTappingFingerprint.toErrorResult()
return PatchResultSuccess()
}
}
@@ -1,15 +1,19 @@
package app.revanced.patches.youtube.interaction.seekbar.patch
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
@DependsOn([SettingsPatch::class])
@DependsOn([SettingsPatch::class, ResourceMappingPatch::class])
class EnableSeekbarTappingResourcePatch : ResourcePatch {
override fun execute(context: ResourceContext) {
override fun execute(context: ResourceContext): PatchResult {
SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences(
SwitchPreference(
"revanced_seekbar_tapping",
@@ -18,5 +22,15 @@ class EnableSeekbarTappingResourcePatch : ResourcePatch {
StringResource("revanced_seekbar_tapping_summary_off", "Seekbar tapping is disabled")
)
)
accessibilityPlayerProgressTime = ResourceMappingPatch.resourceMappings.find {
it.name == "accessibility_player_progress_time"
}?.id ?: return PatchResultError("Failed to find required resource")
return PatchResultSuccess()
}
internal companion object {
var accessibilityPlayerProgressTime = -1L
}
}
@@ -3,6 +3,6 @@ package app.revanced.patches.youtube.interaction.swipecontrols.annotation
import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package
@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35", "18.29.38", "18.32.39"))])
@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))])
@Target(AnnotationTarget.CLASS)
internal annotation class SwipeControlsCompatibility
@@ -2,7 +2,7 @@ package app.revanced.patches.youtube.interaction.swipecontrols.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import com.android.tools.smali.dexlib2.AccessFlags
import org.jf.dexlib2.AccessFlags
object SwipeControlsHostActivityFingerprint : MethodFingerprint(
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
@@ -1,13 +1,15 @@
package app.revanced.patches.youtube.interaction.swipecontrols.patch.bytecode
import app.revanced.extensions.transformMethods
import app.revanced.extensions.traverseClassHierarchy
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.TypeUtil.traverseClassHierarchy
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable
import app.revanced.patches.shared.fingerprints.WatchWhileActivityFingerprint
import app.revanced.patches.youtube.interaction.swipecontrols.annotation.SwipeControlsCompatibility
@@ -15,8 +17,8 @@ import app.revanced.patches.youtube.interaction.swipecontrols.fingerprints.Swipe
import app.revanced.patches.youtube.interaction.swipecontrols.patch.resource.SwipeControlsResourcePatch
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.immutable.ImmutableMethod
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.immutable.ImmutableMethod
@Patch
@Name("Swipe controls")
@@ -35,7 +37,7 @@ class SwipeControlsBytecodePatch : BytecodePatch(
SwipeControlsHostActivityFingerprint
)
) {
override fun execute(context: BytecodeContext) {
override fun execute(context: BytecodeContext): PatchResult {
val wrapperClass = SwipeControlsHostActivityFingerprint.result!!.mutableClass
val targetClass = WatchWhileActivityFingerprint.result!!.mutableClass
@@ -59,5 +61,6 @@ class SwipeControlsBytecodePatch : BytecodePatch(
).toMutable()
}
}
return PatchResultSuccess()
}
}
@@ -1,6 +1,8 @@
package app.revanced.patches.youtube.interaction.swipecontrols.patch.resource
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.settings.preference.impl.*
@@ -10,7 +12,7 @@ import app.revanced.util.resources.ResourceUtils.copyResources
@DependsOn([SettingsPatch::class])
class SwipeControlsResourcePatch : ResourcePatch {
override fun execute(context: ResourceContext) {
override fun execute(context: ResourceContext): PatchResult {
SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences(
PreferenceScreen(
"revanced_swipe_controls_preference_screen",
@@ -100,5 +102,6 @@ class SwipeControlsResourcePatch : ResourcePatch {
"ic_sc_volume_normal.xml"
)
)
return PatchResultSuccess()
}
}