From daf8c98e16dc60c7f82d72db01f3ea72297cb705 Mon Sep 17 00:00:00 2001 From: inotia00 Date: Sun, 9 Apr 2023 07:36:54 +0900 Subject: [PATCH] fix(custom-seekbar-color): App crashes when playing YouTube videos from PlayStore --- .../fingerprints/ControlsOverlayFingerprint.kt | 8 ++++++++ .../ControlsOverlayParentFingerprint.kt | 11 +++++++++++ .../seekbar/seekbarcolor/patch/SeekbarColorPatch.kt | 13 +++++++++++-- 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbarcolor/fingerprints/ControlsOverlayFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbarcolor/fingerprints/ControlsOverlayParentFingerprint.kt diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbarcolor/fingerprints/ControlsOverlayFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbarcolor/fingerprints/ControlsOverlayFingerprint.kt new file mode 100644 index 000000000..0aae84e08 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbarcolor/fingerprints/ControlsOverlayFingerprint.kt @@ -0,0 +1,8 @@ +package app.revanced.patches.youtube.layout.seekbar.seekbarcolor.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint + +object ControlsOverlayFingerprint : MethodFingerprint( + returnType = "V", + customFingerprint = {it.name == ""} +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbarcolor/fingerprints/ControlsOverlayParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbarcolor/fingerprints/ControlsOverlayParentFingerprint.kt new file mode 100644 index 000000000..e7ee33f7d --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbarcolor/fingerprints/ControlsOverlayParentFingerprint.kt @@ -0,0 +1,11 @@ +package app.revanced.patches.youtube.layout.seekbar.seekbarcolor.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.AccessFlags + +object ControlsOverlayParentFingerprint : MethodFingerprint( + returnType = "V", + access = AccessFlags.PRIVATE or AccessFlags.STATIC or AccessFlags.FINAL, + strings = listOf("Error screen presenter should be present") +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbarcolor/patch/SeekbarColorPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbarcolor/patch/SeekbarColorPatch.kt index a38f4ad3d..592118401 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbarcolor/patch/SeekbarColorPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbarcolor/patch/SeekbarColorPatch.kt @@ -5,6 +5,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.addInstruction import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.BytecodePatch @@ -14,10 +15,10 @@ import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.shared.fingerprints.ControlsOverlayStyleFingerprint -import app.revanced.patches.youtube.layout.seekbar.seekbarcolor.fingerprints.ProgressColorFingerprint -import app.revanced.patches.youtube.layout.seekbar.seekbarcolor.fingerprints.SeekbarColorFingerprint +import app.revanced.patches.youtube.layout.seekbar.seekbarcolor.fingerprints.* import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +import app.revanced.util.integrations.Constants.INTEGRATIONS_PATH import app.revanced.util.integrations.Constants.SEEKBAR import org.jf.dexlib2.iface.instruction.OneRegisterInstruction import org.jf.dexlib2.iface.instruction.WideLiteralInstruction @@ -35,6 +36,7 @@ import org.jf.dexlib2.iface.instruction.WideLiteralInstruction @Version("0.0.1") class SeekbarColorPatch : BytecodePatch( listOf( + ControlsOverlayParentFingerprint, ControlsOverlayStyleFingerprint, SeekbarColorFingerprint ) @@ -66,6 +68,13 @@ class SeekbarColorPatch : BytecodePatch( ) ?: return ProgressColorFingerprint.toErrorResult() } ?: return ControlsOverlayStyleFingerprint.toErrorResult() + ControlsOverlayParentFingerprint.result?.let { parentResult -> + ControlsOverlayFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.mutableMethod?.addInstruction( + 0, + "sput-object p1, $INTEGRATIONS_PATH/utils/ReVancedUtils;->context:Landroid/content/Context;" + ) ?: return ControlsOverlayFingerprint.toErrorResult() + } ?: return ControlsOverlayParentFingerprint.toErrorResult() + /* * Add settings */