AdguardTeam / AdguardForAndroid

Open bug tracker for Android version of AdGuard.
https://adguard.com/
1.36k stars 90 forks source link

FFUpdater incompatibility #3904

Closed TPS closed 2 years ago

TPS commented 3 years ago

Issue Details

Behavior

As shown below, FFUpdater says "No Network Connection" on my Android 8.1.0 32-bit Moto G5+, but updates actually download & install when available. On my Android 11 64-bit TCL 10L, everything shows & works as expected (i.e., shows version number instead of errors).

N.B.: Originally filed @ https://github.com/Tobi823/ffupdater/issues/55, but per dev's notes below, it seems to be an AG glitch, since disabling it solves the problem.

Screenshots

Screenshot: ![Screenshot_20210708-072430.png](https://user-images.githubusercontent.com/185902/125164399-04e29400-e160-11eb-8893-945ae9a926d7.png)

Additional Information

Per FFUpdater's dev:

I suspect that something on your smartphone is causing this problem because it works on my devices, I have not receive other bug reports and I changed the code for "internet detection" a "long" time ago (07.05.2021 with version 73.1.3).

I see that you are using a VPN. Can you try it without it?

I narrowed the bug down to this part:

private fun isInternetAvailableNewWay(cm: ConnectivityManager): Boolean {
    val activeNetwork = cm.activeNetwork ?: return false
    val capabilities = cm.getNetworkCapabilities(activeNetwork) ?: return false
    return capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) &&
            capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED)
}

This method evaluates to false/"no internet" if:

  • ConnectivityManager.activeNetwork is null. According to the [documentation](https://developer.android.com/reference/android/net/ConnectivityManager#getActiveNetwork()) this can happen, if there is no default network.
  • ConnectivityManager.getNetworkCapabilities is null. According to the documentation this can happen, if the network is unknown.
  • the current network doesn't have the
    • NET_CAPABILITY_INTERNET (Indicates that this network should be able to reach the internet.) or
    • NET_CAPABILITY_VALIDATED (Indicates that connectivity on this network was successfully validated. For example, for a network with NET_CAPABILITY_INTERNET, it means that Internet connectivity was successfully detected.) capability.

Maybe you have disabled the internet detection on your smartphone (afaik Android phones are pinging Google servers to detect, if they have access to the Internet)? Maybe something different?

Birbber commented 3 years ago

@TPS Hello. Our developers will take a look at this issue although it doesn't seem like an urgent one. Not sure how much time it will take though. We'll let you know once we get any update.

Tobi823 commented 3 years ago

Hi, I'm the developer of the "FFUpdater" app.

The main problem is, that I was unable to check if my app has internet access or not. Only when I have internet, I want to try to download data from the internet.

With this code I could successfully test if internet is available:

private fun isInternetAvailableNewWay(cm: ConnectivityManager): Boolean {
    val activeNetwork = cm.activeNetwork ?: return false
    val capabilities = cm.getNetworkCapabilities(activeNetwork) ?: return false
    return capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) &&
            capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED)
}

But this does no longer work when the VPN from Adguard is active. Even if the smartphone is in airplane mode, my code returns that there is an internet connection. Is this a bug in Adguard or a limitation of the operating system?

I have solved the problem in my app for now by checking if the IP address of api.github.com can be resolved (DNS). This is not perfect, but should be enough for my purposes.

TPS commented 3 years ago

@Tobi823 It still behaves identically in FfU v74.4.3 & AgA v4.0n24(65). 🤷🏾‍♂️

Tobi823 commented 3 years ago

@TPS https://github.com/Tobi823/ffupdater/issues/87

Tobi823 commented 3 years ago

This issue can be closed. I confused the bug from @TPS with another bug.

The real bug is, that his smartphone evaluate capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) to false although it has Internet access.

As far as I can tell, the bug is not related to AdguardForAndroid.

TPS commented 3 years ago

It may not be specific to AGA (e.g., might be w/ any VPN), but it did manifest w/ it on FFU versions < 74.4.5, so it might be worth investigating. @Tobi823 has graciously made a workaround for higher FFU versions, so it might be moot, though.

TPS commented 2 years ago

This is back in FFUpdater under https://github.com/AdguardTeam/AdguardForAndroid/issues/4047's conditions.

TPS commented 2 years ago

Since most recent AG update (v4.0n31), this problem has recurred on all my devices — 32- & 64-bit.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

TPS commented 2 years ago

I think this has been solved, so I'm good w/ closing. If it recurs, I'll repost.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.