From c92a44599f7c89d0feac6d831d6f51fddb2e8f4f Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Sat, 21 Dec 2024 00:35:29 +0400 Subject: [PATCH] refactor --- .../shared/spoof/SpoofVideoStreamsPatch.java | 17 ++++++++++++++++- .../patches/ForceOriginalAudioPatch.java | 18 ------------------ .../extension/youtube/settings/Settings.java | 4 ++-- .../patches/shared/misc/spoof/Fingerprints.kt | 2 +- 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/extensions/shared/library/src/main/java/app/revanced/extension/shared/spoof/SpoofVideoStreamsPatch.java b/extensions/shared/library/src/main/java/app/revanced/extension/shared/spoof/SpoofVideoStreamsPatch.java index 1758f9556f..fe3d684bb5 100644 --- a/extensions/shared/library/src/main/java/app/revanced/extension/shared/spoof/SpoofVideoStreamsPatch.java +++ b/extensions/shared/library/src/main/java/app/revanced/extension/shared/spoof/SpoofVideoStreamsPatch.java @@ -10,6 +10,7 @@ import app.revanced.extension.shared.Logger; import app.revanced.extension.shared.Utils; import app.revanced.extension.shared.settings.BaseSettings; +import app.revanced.extension.shared.settings.EnumSetting; import app.revanced.extension.shared.settings.Setting; import app.revanced.extension.shared.spoof.requests.StreamingDataRequest; @@ -29,10 +30,24 @@ public class SpoofVideoStreamsPatch { /** * @return If this patch was included during patching. */ - public static boolean isPatchIncluded() { + private static boolean isPatchIncluded() { return false; // Modified during patching. } + public static final class NotSpoofingAndroidVrAvailability implements Setting.Availability { + @Override + public boolean isAvailable() { + if (SpoofVideoStreamsPatch.isPatchIncluded()) { + EnumSetting clientType = BaseSettings.SPOOF_VIDEO_STREAMS_CLIENT_TYPE; + return clientType.isAvailable() && clientType.get() != ClientType.ANDROID_VR; + } + + return true; + } + } + + + /** * Injection point. * Blocks /get_watch requests by returning an unreachable URI. diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/ForceOriginalAudioPatch.java b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/ForceOriginalAudioPatch.java index c052fe9f60..91b2fe67a2 100644 --- a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/ForceOriginalAudioPatch.java +++ b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/ForceOriginalAudioPatch.java @@ -1,11 +1,6 @@ package app.revanced.extension.youtube.patches; import app.revanced.extension.shared.Logger; -import app.revanced.extension.shared.settings.BaseSettings; -import app.revanced.extension.shared.settings.EnumSetting; -import app.revanced.extension.shared.settings.Setting; -import app.revanced.extension.shared.spoof.ClientType; -import app.revanced.extension.shared.spoof.SpoofVideoStreamsPatch; import app.revanced.extension.youtube.settings.Settings; @SuppressWarnings("unused") @@ -13,19 +8,6 @@ public class ForceOriginalAudioPatch { private static final String DEFAULT_AUDIO_TRACKS_SUFFIX = ".4"; - public static final class ForceOriginalAudioAvailability implements Setting.Availability { - @Override - public boolean isAvailable() { - if (SpoofVideoStreamsPatch.isPatchIncluded()) { - // Force audio does not work with Android VR. - EnumSetting clientType = BaseSettings.SPOOF_VIDEO_STREAMS_CLIENT_TYPE; - return clientType.isAvailable() && clientType.get() != ClientType.ANDROID_VR; - } - - return true; - } - } - /** * Injection point. */ diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java b/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java index cbfe44891c..c2995dd34f 100644 --- a/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java +++ b/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java @@ -7,8 +7,8 @@ import static app.revanced.extension.shared.settings.Setting.migrateOldSettingToNew; import static app.revanced.extension.shared.settings.Setting.parent; import static app.revanced.extension.shared.settings.Setting.parentsAny; +import static app.revanced.extension.shared.spoof.SpoofVideoStreamsPatch.NotSpoofingAndroidVrAvailability; import static app.revanced.extension.youtube.patches.ChangeStartPagePatch.StartPage; -import static app.revanced.extension.youtube.patches.ForceOriginalAudioPatch.ForceOriginalAudioAvailability; import static app.revanced.extension.youtube.patches.MiniplayerPatch.MiniplayerHideExpandCloseAvailability; import static app.revanced.extension.youtube.patches.MiniplayerPatch.MiniplayerHorizontalDragAvailability; import static app.revanced.extension.youtube.patches.MiniplayerPatch.MiniplayerType; @@ -54,7 +54,7 @@ public class Settings extends BaseSettings { public static final StringSetting CUSTOM_PLAYBACK_SPEEDS = new StringSetting("revanced_custom_playback_speeds", "0.25\n0.5\n0.75\n0.9\n0.95\n1.0\n1.05\n1.1\n1.25\n1.5\n1.75\n2.0\n3.0\n4.0\n5.0", true); // Audio - public static final BooleanSetting FORCE_ORIGINAL_AUDIO = new BooleanSetting("revanced_force_original_audio", FALSE, new ForceOriginalAudioAvailability()); + public static final BooleanSetting FORCE_ORIGINAL_AUDIO = new BooleanSetting("revanced_force_original_audio", FALSE, new NotSpoofingAndroidVrAvailability()); // Ads public static final BooleanSetting HIDE_BUTTONED_ADS = new BooleanSetting("revanced_hide_buttoned_ads", TRUE); diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/misc/spoof/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/shared/misc/spoof/Fingerprints.kt index f0814c1502..c4a581c52a 100644 --- a/patches/src/main/kotlin/app/revanced/patches/shared/misc/spoof/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/shared/misc/spoof/Fingerprints.kt @@ -123,7 +123,7 @@ internal val hlsCurrentTimeFingerprint = fingerprint { } internal val patchIncludedExtensionMethodFingerprint = fingerprint { - accessFlags(AccessFlags.PUBLIC, AccessFlags.STATIC) + accessFlags(AccessFlags.PRIVATE, AccessFlags.STATIC) returns("Z") parameters() custom { method, classDef ->