Skip to content

Conversation

@alperozturk96
Copy link
Collaborator

@alperozturk96 alperozturk96 commented Jan 2, 2026

  • Tests written, or not not needed

Fixes: #14681

Deduplicates isNetworkAndServerAvailable logic

Removes c.isWifi() && !c.isMetered() from internet walled logic since isConnected already covers local internet and internet access

Implements ConnectivityManager.NetworkCallback for better network state listening

Removes deprecated logics

Adds better documentation

Signed-off-by: alperozturk <alper_ozturk@proton.me>
Signed-off-by: alperozturk <alper_ozturk@proton.me>
Signed-off-by: alperozturk <alper_ozturk@proton.me>
Signed-off-by: alperozturk <alper_ozturk@proton.me>
Signed-off-by: alperozturk96 <alper_ozturk@proton.me>
Signed-off-by: alperozturk96 <alper_ozturk@proton.me>
@github-actions
Copy link

Codacy

SpotBugs

CategoryBaseNew
Bad practice4242
Correctness7476
Dodgy code257256
Experimental11
Internationalization77
Malicious code vulnerability22
Multithreaded correctness3434
Performance4444
Security1818
Total479480

SpotBugs increased!

@github-actions
Copy link

@github-actions
Copy link

blue-Light-Screenshot test failed, but no output was generated. Maybe a preliminary stage failed.

@github-actions
Copy link

APK file: https://www.kaminsky.me/nc-dev/android-artifacts/16232.apk

qrcode

To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.

Copy link
Collaborator

@ZetaTom ZetaTom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code-wise this looks good to me. I've added a few minor suggestions about the comments.

I'm currently testing this pull request but this will take a bit longer due to the shear amount of scenarios considering the following:

  • Aeroplane Mode
  • WiFi, Mobile, or both
  • In-app manual upload
  • 'Share to Nextcloud' manual upload
  • Auto Upload
  • Auto Upload (only on unmetered WiFi)
  • VPN connections

I came up with a Matrix to test most of these combinations and will share my findings tomorrow, hopefully.

Comment on lines +66 to +79
*
* <p>The implementation performs the following steps:</p>
* <ul>
* <li>Uses cached results from {@link WalledCheckCache} when available to avoid
* redundant network calls.</li>
* <li>Retrieves the active {@link Server} from {@link UserAccountManager}.</li>
* <li>If connected issues a lightweight
* HTTP {@code GET} request to the server’s <code>/index.php/204</code> endpoint
* (which should respond with HTTP 204 No Content when connectivity is healthy).</li>
* <li>If the response differs from the expected 204 No Content, the connection is
* assumed to be behind a captive portal or otherwise restricted.</li>
* <li>If no active network or server is detected, the method assumes the Internet
* is walled.</li>
* </ul>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
*
* <p>The implementation performs the following steps:</p>
* <ul>
* <li>Uses cached results from {@link WalledCheckCache} when available to avoid
* redundant network calls.</li>
* <li>Retrieves the active {@link Server} from {@link UserAccountManager}.</li>
* <li>If connected issues a lightweight
* HTTP {@code GET} request to the servers <code>/index.php/204</code> endpoint
* (which should respond with HTTP 204 No Content when connectivity is healthy).</li>
* <li>If the response differs from the expected 204 No Content, the connection is
* assumed to be behind a captive portal or otherwise restricted.</li>
* <li>If no active network or server is detected, the method assumes the Internet
* is walled.</li>
* </ul>

As this is an interface it should only serve as a general description of the function and not describe the implementation.

Comment on lines +30 to +35
* <p>The check is based on {@link #isInternetWalled()} — if the Internet is not
* walled (i.e., the server is reachable and not restricted by a captive portal),
* this method reports {@code true}. Otherwise, it reports {@code false}.</p>
*
* @param callback A callback to handle the result of the network and server availability check.
* @param callback a callback that receives {@code true} when the network and
* Nextcloud server are reachable, or {@code false} otherwise.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should only reference isInternetWalled() and not describe what that function returns as this is documented in the function itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upload Failure with "No Internet Connection" Message After Upgrading to Version 3.31.0 on Android App

2 participants