From 6230297b0359f5c95f7120ea978099decbc164c6 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Thu, 26 Sep 2024 07:51:34 -0400 Subject: [PATCH] fix(YouTube - Check watch history domain name resolution): Do not show warning if network connection is flaky (#702) --- .../java/app/revanced/integrations/shared/Utils.java | 4 ++-- .../CheckWatchHistoryDomainNameResolutionPatch.java | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/integrations/java/app/revanced/integrations/shared/Utils.java b/integrations/java/app/revanced/integrations/shared/Utils.java index 22ed1e062..0192c5719 100644 --- a/integrations/java/app/revanced/integrations/shared/Utils.java +++ b/integrations/java/app/revanced/integrations/shared/Utils.java @@ -386,10 +386,10 @@ public class Utils { } /** - * Ignore this class. It must be public to satisfy Android requirement. + * Ignore this class. It must be public to satisfy Android requirements. */ @SuppressWarnings("deprecation") - public static class DialogFragmentWrapper extends DialogFragment { + public static final class DialogFragmentWrapper extends DialogFragment { private Dialog dialog; @Nullable diff --git a/integrations/java/app/revanced/integrations/youtube/patches/CheckWatchHistoryDomainNameResolutionPatch.java b/integrations/java/app/revanced/integrations/youtube/patches/CheckWatchHistoryDomainNameResolutionPatch.java index da294d722..4fab39280 100644 --- a/integrations/java/app/revanced/integrations/youtube/patches/CheckWatchHistoryDomainNameResolutionPatch.java +++ b/integrations/java/app/revanced/integrations/youtube/patches/CheckWatchHistoryDomainNameResolutionPatch.java @@ -20,7 +20,6 @@ public class CheckWatchHistoryDomainNameResolutionPatch { private static final String SINKHOLE_IPV4 = "0.0.0.0"; private static final String SINKHOLE_IPV6 = "::"; - /** @noinspection SameParameterValue */ private static boolean domainResolvesToValidIP(String host) { try { InetAddress address = InetAddress.getByName(host); @@ -50,7 +49,16 @@ public class CheckWatchHistoryDomainNameResolutionPatch { Utils.runOnBackgroundThread(() -> { try { - if (domainResolvesToValidIP(HISTORY_TRACKING_ENDPOINT)) { + // If the user has a flaky DNS server, or they just lost internet connectivity + // and the isNetworkConnected() check has not detected it yet (it can take a few + // seconds after losing connection), then the history tracking endpoint will + // show a resolving error but it's actually an internet connection problem. + // + // Prevent this false positive by verify youtube.com resolves. + // If youtube.com does not resolve, then it's not a watch history domain resolving error + // because the entire app will not work since no domains are resolving. + if (domainResolvesToValidIP(HISTORY_TRACKING_ENDPOINT) + || !domainResolvesToValidIP("youtube.com")) { return; }