fix(youtube/disable-startup-shorts-player): do not prevent playing videos on startup (#714)

This commit is contained in:
OxrxL 2022-10-04 01:40:11 +02:00 committed by GitHub
parent 798bdee9a0
commit 9a0d3798af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 24 deletions

View File

@ -9,11 +9,11 @@ import app.revanced.patches.youtube.layout.startupshortsreset.annotations.Startu
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
@Name("action-open-shorts-fingerprint")
@MatchingMethod("Lkyt;", "l")
@Name("user-was-in-shorts-fingerprint")
@MatchingMethod("Lkzb;", "e")
@StartupShortsResetCompatibility
@Version("0.0.1")
object ActionOpenShortsFingerprint : MethodFingerprint(
"V", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf("L", "L"),
strings = listOf("com.google.android.youtube.action.open.shorts"),
object UserWasInShortsFingerprint : MethodFingerprint(
"V", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf("L"),
strings = listOf("Failed to read user_was_in_shorts proto after successful warmup"),
)

View File

@ -11,14 +11,11 @@ import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.patch.impl.BytecodePatch
import app.revanced.patches.youtube.layout.startupshortsreset.annotations.StartupShortsResetCompatibility
import app.revanced.patches.youtube.layout.startupshortsreset.fingerprints.ActionOpenShortsFingerprint
import app.revanced.patches.youtube.layout.startupshortsreset.fingerprints.UserWasInShortsFingerprint
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource
import app.revanced.patches.youtube.misc.settings.framework.components.impl.SwitchPreference
import org.jf.dexlib2.builder.instruction.BuilderInstruction21c
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
@Patch
@DependsOn([IntegrationsPatch::class, SettingsPatch::class])
@ -28,7 +25,7 @@ import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
@Version("0.0.1")
class DisableShortsOnStartupPatch : BytecodePatch(
listOf(
ActionOpenShortsFingerprint
UserWasInShortsFingerprint
)
) {
override fun execute(data: BytecodeData): PatchResult {
@ -42,22 +39,14 @@ class DisableShortsOnStartupPatch : BytecodePatch(
)
)
val actionOpenShortsResult = ActionOpenShortsFingerprint.result
val actionOpenShortsMethod = actionOpenShortsResult!!.mutableMethod
val actionOpenShortsInstructions = actionOpenShortsMethod.implementation!!.instructions
val userWasInShortsMethod = UserWasInShortsFingerprint.result!!.mutableMethod
val moveResultIndex = actionOpenShortsResult.scanResult.stringsScanResult!!.matches.first().index + 4
val iPutBooleanIndex = moveResultIndex + 2
val moveResultRegister = (actionOpenShortsInstructions[moveResultIndex] as OneRegisterInstruction).registerA
val iPutBooleanRegister = (actionOpenShortsInstructions[iPutBooleanIndex] as TwoRegisterInstruction).registerA
actionOpenShortsMethod.addInstructions(
moveResultIndex + 1, """
userWasInShortsMethod.addInstructions(
0, """
invoke-static { }, Lapp/revanced/integrations/patches/DisableStartupShortsPlayerPatch;->disableStartupShortsPlayer()Z
move-result v$moveResultRegister
if-eqz v$moveResultRegister, :cond_startup_shorts_reset
const/4 v$iPutBooleanRegister, 0x0
move-result v0
if-eqz v0, :cond_startup_shorts_reset
return-void
:cond_startup_shorts_reset
nop
"""