From 5bf5fbd1a79389895991f6b672d87373e96b698c Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Sun, 4 Aug 2024 15:38:07 -0400 Subject: [PATCH] fix(YouTube - Spoof client): Restore livestream audio only playback with iOS spoofing (#673) --- .../revanced/integrations/shared/Utils.java | 2 +- .../patches/spoof/SpoofClientPatch.java | 29 ++++++------------- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/app/revanced/integrations/shared/Utils.java b/app/src/main/java/app/revanced/integrations/shared/Utils.java index f0c17e8c..4b13a787 100644 --- a/app/src/main/java/app/revanced/integrations/shared/Utils.java +++ b/app/src/main/java/app/revanced/integrations/shared/Utils.java @@ -273,7 +273,6 @@ public class Utils { @NonNull MatchFilter filter) { for (int i = 0, childCount = viewGroup.getChildCount(); i < childCount; i++) { View childAt = viewGroup.getChildAt(i); - Logger.printDebug(() -> "View id: " + childAt.getId() + " tag: " + childAt.getTag()); if (filter.matches(childAt)) { //noinspection unchecked @@ -285,6 +284,7 @@ public class Utils { if (match != null) return match; } } + return null; } diff --git a/app/src/main/java/app/revanced/integrations/youtube/patches/spoof/SpoofClientPatch.java b/app/src/main/java/app/revanced/integrations/youtube/patches/spoof/SpoofClientPatch.java index a83bf2a6..2b29dd97 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/patches/spoof/SpoofClientPatch.java +++ b/app/src/main/java/app/revanced/integrations/youtube/patches/spoof/SpoofClientPatch.java @@ -5,6 +5,7 @@ import android.media.MediaCodecList; import android.net.Uri; import android.os.Build; import app.revanced.integrations.shared.Logger; +import app.revanced.integrations.youtube.patches.BackgroundPlaybackPatch; import app.revanced.integrations.youtube.settings.Settings; import org.chromium.net.ExperimentalUrlRequest; @@ -20,13 +21,6 @@ public class SpoofClientPatch { private static final String UNREACHABLE_HOST_URI_STRING = "https://127.0.0.0"; private static final Uri UNREACHABLE_HOST_URI = Uri.parse(UNREACHABLE_HOST_URI_STRING); - /** - * Tracking URL authority to use when spoofing the client to iOS, - * because watch history is not working on brand accounts. - * See LuanRT/YouTube.js. - */ - private static final String WWW_TRACKING_URL_AUTHORITY = "www.youtube.com"; - /** * Injection point. * Blocks /get_watch requests by returning an unreachable URI. @@ -128,6 +122,14 @@ public class SpoofClientPatch { return SPOOFING_TO_IOS || original; } + /** + * Injection point. + * When spoofing the client to iOS, background audio only playback of livestreams fails. + * Return true to force enable audio background play. + */ + public static boolean overrideBackgroundAudioPlayback() { + return SPOOFING_TO_IOS && BackgroundPlaybackPatch.playbackIsNotShort(); + } /** * Injection point. @@ -144,19 +146,6 @@ public class SpoofClientPatch { return builder.build(); } - /** - * Injection point. - * When spoofing the client to iOS, history is not working on brand accounts. - * Replace the tracking URL authority to {@link SpoofClientPatch#WWW_TRACKING_URL_AUTHORITY} to fix this. - */ - public static Uri overrideTrackingUrl(Uri trackingUrl) { - if (SPOOF_CLIENT_ENABLED && SPOOF_CLIENT_TYPE == ClientType.IOS) { - return trackingUrl.buildUpon().authority(WWW_TRACKING_URL_AUTHORITY).build(); - } - - return trackingUrl; - } - private enum ClientType { // https://dumps.tadiphone.dev/dumps/oculus/eureka ANDROID_VR(28,