feat: swipe-controls rewrite (#131)

* move patch 'fenster' to 'swipe-controls'

* remove 'injectIntoNamedMethod' function

* move updatePlayerType hook into its own patch

* refactor 'swipe-controls' patch

* add resources for new ui to patch

Co-authored-by: TheJeterLP <joey.peter1998@gmail.com>
This commit is contained in:
Chris
2022-07-11 14:29:46 +02:00
committed by GitHub
parent ffe68a108e
commit b7dba09927
13 changed files with 224 additions and 152 deletions

View File

@ -0,0 +1,13 @@
package app.revanced.patches.youtube.misc.playertype.annotation
import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package
@Compatibility(
[Package(
"com.google.android.youtube", arrayOf("17.24.34", "17.25.34", "17.26.35")
)]
)
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
internal annotation class PlayerTypeHookCompatibility

View File

@ -0,0 +1,46 @@
package app.revanced.patches.youtube.misc.playertype.fingerprint
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod
import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.interaction.swipecontrols.annotation.SwipeControlsCompatibility
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
//TODO constrain to only match in YoutubePlayerOverlaysLayout?
@Name("update-player-type-fingerprint")
@MatchingMethod(
"LYoutubePlayerOverlaysLayout;",
"nM"
)
@FuzzyPatternScanMethod(2)
@SwipeControlsCompatibility
@Version("0.0.1")
object UpdatePlayerTypeFingerprint : MethodFingerprint(
"V",
AccessFlags.PUBLIC or AccessFlags.FINAL,
null,
listOf(
Opcode.INVOKE_VIRTUAL,
Opcode.IGET_OBJECT,
Opcode.IF_NE,
Opcode.RETURN_VOID,
Opcode.IPUT_OBJECT,
Opcode.INVOKE_DIRECT,
Opcode.INVOKE_VIRTUAL,
Opcode.INVOKE_VIRTUAL,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT,
Opcode.IF_EQZ,
Opcode.CONST_4,
Opcode.INVOKE_STATIC,
Opcode.RETURN_VOID,
Opcode.CONST_4,
Opcode.INVOKE_STATIC,
Opcode.INVOKE_VIRTUAL,
Opcode.RETURN_VOID
)
)

View File

@ -0,0 +1,34 @@
package app.revanced.patches.youtube.misc.playertype.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.impl.BytecodeData
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.Dependencies
import app.revanced.patcher.patch.impl.BytecodePatch
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.misc.playertype.annotation.PlayerTypeHookCompatibility
import app.revanced.patches.youtube.misc.playertype.fingerprint.UpdatePlayerTypeFingerprint
@Name("player-type-hook")
@Description("hook to get the current player type of WatchWhileActivity")
@PlayerTypeHookCompatibility
@Version("0.0.1")
@Dependencies(dependencies = [IntegrationsPatch::class])
class PlayerTypeHookPatch : BytecodePatch(
listOf(
UpdatePlayerTypeFingerprint
)
) {
override fun execute(data: BytecodeData): PatchResult {
// hook YouTubePlayerOverlaysLayout.updatePlayerLayout()
UpdatePlayerTypeFingerprint.result!!.mutableMethod.addInstruction(
0,
"invoke-static { p1 }, Lapp/revanced/integrations/patches/PlayerTypeHookPatch;->YouTubePlayerOverlaysLayout_updatePlayerTypeHookEX(Ljava/lang/Object;)V"
)
return PatchResultSuccess()
}
}