feat(YouTube): Add experimental support for 21.20.493
Co-Authored-By: LisoUseInAIKyrios <118716522+lisouseinaikyrios@users.noreply.github.com>
This commit is contained in:
parent
20079d267a
commit
7f52ec2cea
4 changed files with 37 additions and 8 deletions
|
|
@ -1,5 +1,7 @@
|
|||
package app.revanced.extension.youtube.patches;
|
||||
|
||||
import static app.revanced.extension.youtube.patches.VersionCheckPatch.IS_21_10_OR_GREATER;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
|
@ -24,7 +26,12 @@ public class ShortsAutoplayPatch {
|
|||
/**
|
||||
* Pause playback after 1 play.
|
||||
*/
|
||||
END_SCREEN;
|
||||
END_SCREEN,
|
||||
/**
|
||||
* Play once, then advanced to the next Short.
|
||||
* Only found in 21.10+
|
||||
*/
|
||||
AUTO_ADVANCE;
|
||||
|
||||
static void setYTEnumValue(Enum<?> ytBehavior) {
|
||||
for (ShortsLoopBehavior rvBehavior : values()) {
|
||||
|
|
@ -93,8 +100,12 @@ public class ShortsAutoplayPatch {
|
|||
autoplay = Settings.SHORTS_AUTOPLAY.get();
|
||||
}
|
||||
|
||||
Enum<?> overrideBehavior = (autoplay
|
||||
ShortsLoopBehavior autoPlayBehavior = IS_21_10_OR_GREATER
|
||||
? ShortsLoopBehavior.SINGLE_PLAY
|
||||
: ShortsLoopBehavior.AUTO_ADVANCE;
|
||||
|
||||
Enum<?> overrideBehavior = (autoplay
|
||||
? autoPlayBehavior
|
||||
: ShortsLoopBehavior.REPEAT).ytEnumValue;
|
||||
|
||||
if (overrideBehavior != null) {
|
||||
|
|
|
|||
|
|
@ -27,4 +27,6 @@ public class VersionCheckPatch {
|
|||
public static final boolean IS_20_31_OR_GREATER = isVersionOrGreater("20.31.00");
|
||||
|
||||
public static final boolean IS_20_37_OR_GREATER = isVersionOrGreater("20.37.00");
|
||||
|
||||
public static final boolean IS_21_10_OR_GREATER = isVersionOrGreater("21.10.00");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
|||
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
|
||||
import app.revanced.patches.youtube.misc.playservice.is_19_34_or_greater
|
||||
import app.revanced.patches.youtube.misc.playservice.is_20_09_or_greater
|
||||
import app.revanced.patcher.method
|
||||
import app.revanced.patches.youtube.misc.playservice.is_21_10_or_greater
|
||||
import app.revanced.patches.youtube.misc.playservice.versionCheckPatch
|
||||
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
|
||||
import app.revanced.patches.youtube.misc.settings.settingsPatch
|
||||
|
|
@ -99,12 +101,23 @@ val shortsAutoplayPatch = bytecodePatch(
|
|||
|
||||
reelPlaybackRepeatMethod.apply {
|
||||
// The behavior enums are looked up from an ordinal value to an enum type.
|
||||
findInstructionIndicesReversedOrThrow {
|
||||
val reference = getReference<MethodReference>()
|
||||
reference?.definingClass == reelEnumClass &&
|
||||
reference.parameterTypes.firstOrNull() == "I" &&
|
||||
reference.returnType == reelEnumClass
|
||||
}.forEach { index ->
|
||||
|
||||
val match = if (is_21_10_or_greater) {
|
||||
method {
|
||||
returnType == reelEnumClass &&
|
||||
parameterTypes.size == 1 &&
|
||||
parameterTypes[0].startsWith("L")
|
||||
}
|
||||
} else {
|
||||
method {
|
||||
definingClass == "reelEnumClass" &&
|
||||
returnType == reelEnumClass &&
|
||||
parameterTypes.size == 1 &&
|
||||
parameterTypes[0].startsWith("L")
|
||||
}
|
||||
}
|
||||
|
||||
findInstructionIndicesReversedOrThrow { match(0, 0) {} }.forEach { index ->
|
||||
val register = getInstruction<OneRegisterInstruction>(index + 1).registerA
|
||||
|
||||
addInstructions(
|
||||
|
|
|
|||
|
|
@ -127,6 +127,8 @@ var is_21_07_or_greater : Boolean by Delegates.notNull()
|
|||
private set
|
||||
var is_21_08_or_greater : Boolean by Delegates.notNull()
|
||||
private set
|
||||
var is_21_10_or_greater : Boolean by Delegates.notNull()
|
||||
private set
|
||||
|
||||
val versionCheckPatch = resourcePatch(
|
||||
description = "Uses the Play Store service version to find the major/minor version of the YouTube target app.",
|
||||
|
|
@ -184,5 +186,6 @@ val versionCheckPatch = resourcePatch(
|
|||
is_21_06_or_greater = 260705000 <= playStoreServicesVersion
|
||||
is_21_07_or_greater = 260805000 <= playStoreServicesVersion
|
||||
is_21_08_or_greater = 260905000 <= playStoreServicesVersion
|
||||
is_21_10_or_greater = 261080000 <= playStoreServicesVersion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue