mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-11 12:04:39 +02:00
fix(YouTube/Disable resuming shorts on startup): not worked due to A/B tests
This commit is contained in:
parent
dec9ae8f7d
commit
c02510a289
@ -8,11 +8,15 @@ import app.revanced.patcher.patch.BytecodePatch
|
|||||||
import app.revanced.patcher.patch.PatchException
|
import app.revanced.patcher.patch.PatchException
|
||||||
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||||
import app.revanced.patcher.patch.annotation.Patch
|
import app.revanced.patcher.patch.annotation.Patch
|
||||||
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||||
|
import app.revanced.patcher.util.smali.ExternalLabel
|
||||||
|
import app.revanced.patches.youtube.shorts.startupshortsreset.fingerprints.UserWasInShortsABConfigFingerprint
|
||||||
import app.revanced.patches.youtube.shorts.startupshortsreset.fingerprints.UserWasInShortsFingerprint
|
import app.revanced.patches.youtube.shorts.startupshortsreset.fingerprints.UserWasInShortsFingerprint
|
||||||
import app.revanced.patches.youtube.utils.integrations.Constants.SHORTS
|
import app.revanced.patches.youtube.utils.integrations.Constants.SHORTS
|
||||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||||
import app.revanced.util.exception
|
import app.revanced.util.exception
|
||||||
import app.revanced.util.getStringInstructionIndex
|
import app.revanced.util.getStringInstructionIndex
|
||||||
|
import app.revanced.util.getTargetIndex
|
||||||
import app.revanced.util.getTargetIndexReversed
|
import app.revanced.util.getTargetIndexReversed
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||||
@ -54,10 +58,36 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
|
|||||||
)
|
)
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
object DisableResumingShortsOnStartupPatch : BytecodePatch(
|
object DisableResumingShortsOnStartupPatch : BytecodePatch(
|
||||||
setOf(UserWasInShortsFingerprint)
|
setOf(
|
||||||
|
UserWasInShortsABConfigFingerprint,
|
||||||
|
UserWasInShortsFingerprint
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext) {
|
override fun execute(context: BytecodeContext) {
|
||||||
|
|
||||||
|
UserWasInShortsABConfigFingerprint.result?.let {
|
||||||
|
val insertMethod = context.toMethodWalker(it.method)
|
||||||
|
.nextMethod(it.scanResult.patternScanResult!!.startIndex, true)
|
||||||
|
.getMethod() as MutableMethod
|
||||||
|
|
||||||
|
// This method will only be called for the user being A/B tested.
|
||||||
|
// Presumably a method that processes the ProtoDataStore value (boolean) for the 'user_was_in_shorts' key.
|
||||||
|
insertMethod.apply {
|
||||||
|
val insertIndex = getTargetIndex(Opcode.IGET_OBJECT)
|
||||||
|
val insertRegister = getInstruction<TwoRegisterInstruction>(insertIndex).registerA
|
||||||
|
|
||||||
|
addInstructionsWithLabels(
|
||||||
|
insertIndex, """
|
||||||
|
invoke-static {}, $SHORTS->disableResumingStartupShortsPlayer()Z
|
||||||
|
move-result v$insertRegister
|
||||||
|
if-eqz v$insertRegister, :show
|
||||||
|
const/4 v$insertRegister, 0x0
|
||||||
|
return v$insertRegister
|
||||||
|
""", ExternalLabel("show", getInstruction(insertIndex))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} ?: throw UserWasInShortsABConfigFingerprint.exception
|
||||||
|
|
||||||
UserWasInShortsFingerprint.result?.let {
|
UserWasInShortsFingerprint.result?.let {
|
||||||
it.mutableMethod.apply {
|
it.mutableMethod.apply {
|
||||||
val startIndex = getStringInstructionIndex("Failed to read user_was_in_shorts proto after successful warmup")
|
val startIndex = getStringInstructionIndex("Failed to read user_was_in_shorts proto after successful warmup")
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
package app.revanced.patches.youtube.shorts.startupshortsreset.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||||
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This fingerprint is compatible with all YouTube versions after v18.15.40.
|
||||||
|
*/
|
||||||
|
object UserWasInShortsABConfigFingerprint : MethodFingerprint(
|
||||||
|
returnType = "V",
|
||||||
|
opcodes = listOf(
|
||||||
|
Opcode.INVOKE_VIRTUAL,
|
||||||
|
Opcode.MOVE_RESULT,
|
||||||
|
Opcode.INVOKE_VIRTUAL,
|
||||||
|
Opcode.MOVE_RESULT,
|
||||||
|
Opcode.INVOKE_VIRTUAL,
|
||||||
|
Opcode.MOVE_RESULT,
|
||||||
|
Opcode.INVOKE_VIRTUAL
|
||||||
|
),
|
||||||
|
strings = listOf("Failed to get offline response: ")
|
||||||
|
)
|
Loading…
x
Reference in New Issue
Block a user