fix: revert swipe-controls patch

This reverts commit 1d0a7dcc0c.
This commit is contained in:
oSumAtrIX
2022-07-05 23:24:10 +02:00
committed by GitHub
parent 587937b876
commit 66e1f3384a
4 changed files with 0 additions and 300 deletions

View File

@ -1,14 +0,0 @@
package app.revanced.patches.youtube.interaction.fenster.annotation
import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package
//TODO the patch may be compatible with more versions, but this is the one i'm testing on right now...
@Compatibility(
[Package(
"com.google.android.youtube", arrayOf("17.24.34")
)]
)
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
internal annotation class FensterCompatibility

View File

@ -1,45 +0,0 @@
package app.revanced.patches.youtube.interaction.fenster.fingerprints
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.fenster.annotation.FensterCompatibility
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
@Name("update-player-type-fingerprint")
@MatchingMethod(
"LYoutubePlayerOverlaysLayout;",
"nM"
)
@FuzzyPatternScanMethod(2)
@FensterCompatibility
@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

@ -1,121 +0,0 @@
package app.revanced.patches.youtube.interaction.fenster.patch
import app.revanced.extensions.injectConsumableEventHook
import app.revanced.extensions.injectIntoNamedMethod
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.fingerprint.method.impl.MethodFingerprintResult
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.Dependencies
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.patch.impl.BytecodePatch
import app.revanced.patches.youtube.interaction.fenster.annotation.FensterCompatibility
import app.revanced.patches.youtube.interaction.fenster.fingerprints.UpdatePlayerTypeFingerprint
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import org.jf.dexlib2.immutable.reference.ImmutableMethodReference
@Patch
@Name("fenster-swipe-controls")
@Description("volume and brightness swipe controls")
@FensterCompatibility
@Version("0.0.1")
@Dependencies(dependencies = [IntegrationsPatch::class])
class FensterPatch : BytecodePatch(
listOf(
UpdatePlayerTypeFingerprint
)
) {
override fun execute(data: BytecodeData): PatchResult {
// hook WatchWhileActivity.onStart (main activity lifecycle hook)
data.injectIntoNamedMethod(
"com/google/android/apps/youtube/app/watchwhile/WatchWhileActivity",
"onStart",
0,
"invoke-static { p0 }, Lapp/revanced/integrations/patches/FensterSwipePatch;->WatchWhileActivity_onStartHookEX(Ljava/lang/Object;)V"
)
// hook YoutubePlayerOverlaysLayout.onFinishInflate (player overlays init hook)
data.injectIntoNamedMethod(
"com/google/android/apps/youtube/app/common/player/overlay/YouTubePlayerOverlaysLayout",
"onFinishInflate",
-2,
"invoke-static { p0 }, Lapp/revanced/integrations/patches/FensterSwipePatch;->YouTubePlayerOverlaysLayout_onFinishInflateHookEX(Ljava/lang/Object;)V"
)
// hook YoutubePlayerOverlaysLayout.UpdatePlayerType
injectUpdatePlayerTypeHook(
UpdatePlayerTypeFingerprint.result!!,
"com/google/android/apps/youtube/app/common/player/overlay/YouTubePlayerOverlaysLayout"
)
// hook NextGenWatchLayout.onTouchEvent and NextGenWatchLayout.onInterceptTouchEvent (player touch event hook)
injectWatchLayoutTouchHooks(
data,
"com/google/android/apps/youtube/app/watch/nextgenwatch/ui/NextGenWatchLayout"
)
return PatchResultSuccess()
}
@Suppress("SameParameterValue")
private fun injectUpdatePlayerTypeHook(fingerPrintResult: MethodFingerprintResult, targetClass: String) {
// validate fingerprint found the right class
if (!fingerPrintResult.classDef.type.endsWith("$targetClass;")) {
throw PatchResultError("$targetClass.UpdatePlayerType fingerprint could not be validated")
}
// insert the hook
fingerPrintResult.mutableMethod.addInstruction(
0,
"invoke-static { p1 }, Lapp/revanced/integrations/patches/FensterSwipePatch;->YouTubePlayerOverlaysLayout_updatePlayerTypeHookEX(Ljava/lang/Object;)V"
)
}
/**
* Inject onTouch event hooks into the watch layout class
*
* @param data bytecode data
* @param targetClass watch layout class name
*/
@Suppress("SameParameterValue")
private fun injectWatchLayoutTouchHooks(data: BytecodeData, targetClass: String) {
var touchHooksCount = 0
data.classes.filter { it.type.endsWith("$targetClass;") }.forEach { classDef ->
// hook onTouchEvent
data.proxy(classDef).resolve().methods.filter { it.name == "onTouchEvent" }.forEach { methodDef ->
touchHooksCount++
methodDef.injectConsumableEventHook(
ImmutableMethodReference(
"Lapp/revanced/integrations/patches/FensterSwipePatch;",
"NextGenWatchLayout_onTouchEventHookEX",
listOf("Ljava/lang/Object;", "Ljava/lang/Object;"),
"Z"
)
)
}
// hook onInterceptTouchEvent
data.proxy(classDef).resolve().methods.filter { it.name == "onInterceptTouchEvent" }.forEach { methodDef ->
touchHooksCount++
methodDef.injectConsumableEventHook(
ImmutableMethodReference(
"Lapp/revanced/integrations/patches/FensterSwipePatch;",
"NextGenWatchLayout_onInterceptTouchEventHookEX",
listOf("Ljava/lang/Object;", "Ljava/lang/Object;"),
"Z"
)
)
}
}
// fail if no touch hooks were inserted
if (touchHooksCount <= 0) {
throw PatchResultError("failed to inject onTouchEvent hook into NextGenWatchLayout: none found")
}
}
}