Skip to content
This repository has been archived by the owner on Oct 26, 2024. It is now read-only.

Commit

Permalink
fix(YouTube - Check watch history domain name resolution): Do not sho…
Browse files Browse the repository at this point in the history
…w warning if network connection is flaky (#702)
  • Loading branch information
LisoUseInAIKyrios authored Sep 26, 2024
1 parent 87749ee commit 80482df
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/src/main/java/app/revanced/integrations/shared/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,10 @@ public static boolean containsNumber(@NonNull CharSequence text) {
}

/**
* 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -50,7 +49,16 @@ public static void checkDnsResolver(Activity context) {

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;
}

Expand Down

0 comments on commit 80482df

Please sign in to comment.