Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't upload or download data via reverse tethering #6044

Open
alberic89 opened this issue Dec 15, 2024 · 21 comments
Open

Can't upload or download data via reverse tethering #6044

alberic89 opened this issue Dec 15, 2024 · 21 comments
Labels
bug feedback required more info is needed, issue will be likely closed if it is not provided

Comments

@alberic89
Copy link

I can't send or receive any data when I am connected via reverse tethering, the app thinks that I am not connected.
I use gnirethet to connect my phone to internet. I checked with my web browser that I am connected.

This app is not the only one to have this problem. For example, the F-Droid client think that there is no connection but is still able to download applications.

How to Reproduce

  • turn off wifi and mobile connection,
  • set up reverse tethering with gnirethet,
  • open the StreetComplete app,
  • try to download/upload some data,
  • see that it doesn't work

Expected Behavior
The app try to download data. Even if, at first sight, there is no internet connection.

Versions affected
StreetComplete: v60.0
Android: 14

@alberic89 alberic89 added the bug label Dec 15, 2024
@alberic89
Copy link
Author

alberic89 commented Dec 15, 2024

I think that this code is related to the issue :

val isConnected: Boolean get() =
connectivityManager.activeNetworkInfo?.isConnected == true

Duplicated also here:

private val isConnected: Boolean
get() = getSystemService<ConnectivityManager>()?.activeNetworkInfo?.isConnected == true

@rusty-snake
Copy link

Could it be related to OpenStreetMap.org currently offline. Operations Team are working to restore - 15 December 2024? Or did you tried yesterday?

@alberic89
Copy link
Author

I just tried a few minutes ago.
I don't thinks that it is related because when I activate my mobile connection, everything works. But I don't have a big mobile plan.

@matkoniecz
Copy link
Member

there is an ongoing outage on OSM servers, I am unable to save anything

I think that reverse tethering is unrelated, unless it persists after outage

please comment here if you will be still unable to upload/download after https://community.openstreetmap.org/t/openstreetmap-org-currently-offline-operations-team-are-working-to-restore-15-december-2024/122930 is resolved

(unless you see bug in code linked at #6044 (comment) )

@alberic89
Copy link
Author

I am able to download data with a regular connection, so my issue is really due to reverse tethering.
I don't know if I can call this a bug, it is more a non-covered use case.
I am currently trying to write a quick workaround, but I am not on my machine (and I have no competence in mobile application dev), so I can't test it.

@matkoniecz
Copy link
Member

matkoniecz commented Dec 15, 2024

As OSM is in read-only mode: are you 100% sure you cannot read data with reverse tethering while you are able to download something else from internet with reverse tethering?

@alberic89
Copy link
Author

Yes, I am 100% sure.
With reverse tethering activated, I have an error message when i try to download data: "You are offline", and no quest where downloaded. But I can see any webpage in my browser.
If i try with my mobile connection turned on, there is no error message and quest are downloaded.

@mnalis
Copy link
Member

mnalis commented Dec 15, 2024

I am currently trying to write a quick workaround, but I am not on my machine (and I have no competence in mobile application dev), so I can't test it.

@alberic89 You can try changing those isConnected etc. functions to always return true, and then use GitHub actions web button to build the .apk for you to test (see https://github.com/streetcomplete/StreetComplete/blob/master/CONTRIBUTING_A_NEW_QUEST.md#alternative-to-android-studio for details) - you don't need any development environment for that.

Does downloading the quests from OSM works then?

there is an ongoing outage on OSM servers, I am unable to save anything

True, but the issue claims the problem is with downloading data, which should be working now. And OSM-unrelated apps (F-droid) seem to have that problem for them too. So while the timing seems to be unfortunate, but issue is probably not related to current OSM outage AFAICT.

What I am interested @alberic89 is there some (preferably opensource) app which correctly detects online/offline status of that reverse tethering connection (i.e. it does not just blindly try to download and then report error if fails, but checks actual connection status) which works correctly with that reverse tethering solution?

@alberic89
Copy link
Author

@alberic89 You can try changing those isConnected etc. functions to always return true, and then use GitHub actions web button to build the .apk for you to test (see https://github.com/streetcomplete/StreetComplete/blob/master/CONTRIBUTING_A_NEW_QUEST.md#alternative-to-android-studio for details) - you don't need any development environment for that.

Making this allowed me to download all the data with reverse tethering.

I tried to add a button in advanced settings to allow any user to bypass connection check, but I never used Kotlin or Android, so I add an obscure error: https://github.com/alberic89/StreetComplete/actions/runs/12340718236/job/34438517642#step:5:106

@mnalis
Copy link
Member

mnalis commented Dec 15, 2024

Making this allowed me to download all the data with reverse tethering.

Cool, so it is just an "online detection" which is not working in your case @alberic89 !

As StreetComplete is really averse to adding preferences, some automated solution would probably be required1. So if you can pinpoint to some application which detects your reverse tethering as being "online", it could point us to the solution.

Footnotes

  1. alternatively, a preference might be added in SCEE (SC "Expert Edition" fork) if there is absolutely no way to make your (rather uncommon for most users, I'd wager) situation work...

@alberic89
Copy link
Author

alberic89 commented Dec 15, 2024

Oh, I understand that you prefer avoid too much options.
I searched but all the app I found that are working with tethering seems don't really check connection before trying to send a request.

We can try for example to ping the OSM server to test the connection.
I am searching also if this can detect all type of connection: https://developer.android.com/reference/android/net/ConnectivityManager#getNetworkCapabilities(android.net.Network)
EDIT: or maybe we can use a library like this one, but it can be better if we can reduce the number of dependencies : https://github.com/TM-Apps/konnection

@HolgerJeromin
Copy link
Contributor

HolgerJeromin commented Dec 15, 2024

The osm editor vespucci also disable the upload menu without connectivity.
Its detect code is a little bit different.
https://github.com/MarcusWolschon/osmeditor4android/blob/dcabe8084aa15f5551a37c990516bf73398af1bf/src/main/java/de/blau/android/util/NetworkStatus.java#L37
So it would be interesting to try.

The whole thing feels there should be a bug report for gnirethet
Edit: Genymobile/gnirehtet#522 and
Genymobile/gnirehtet#567
But also

This project is not actively maintained anymore

@matkoniecz
Copy link
Member

@alberic89 - is Vespucci network detector working for you?

@matkoniecz matkoniecz added the feedback required more info is needed, issue will be likely closed if it is not provided label Dec 16, 2024
@alberic89
Copy link
Author

The button to download the current view is disabled but I can download the EGM successfully.
And if I activate mobile data, I can download the current view.

@alberic89
Copy link
Author

And of course, bypassing all detection in the source code of Vespucci also worked.

@westnordost
Copy link
Member

Never heard of reverse tethering. What is the use case for this? I.e. why would it be important (for you) that it worked in StreetComplete?

@Jean-BaptisteC
Copy link
Contributor

OSM is back

@PRIMA-RT
Copy link

Never heard of reverse tethering. What is the use case for this? I.e. why would it be important (for you) that it worked in StreetComplete?

Reverse tethering refers to sharing an internet connection from a computer (laptop/desktop) to a mobile device (like a smartphone or tablet) via USB, Wi-Fi, or Bluetooth. This is the reverse of regular tethering, where the phone shares its internet connection with the computer.
-> In short, using something like a hotspot of computer.

@mnalis
Copy link
Member

mnalis commented Dec 18, 2024

I wonder if using NetworkCapabilities.hasCapability() with NET_CAPABILITY_INTERNET (or even NET_CAPABILITY_VALIDATED) would work instead?

Although that workaround (I guess) might give false positives to other users, e.g. if one has some privacy VPN installed and active all the time (like Rethink) but no actual Internet connection (i.e. mobile data and WiFi are turned off) it would still report that as "has Internet", but attempts to download/upload would fail with error.


@alberic89 See possible workarounds mentioned at Genymobile/gnirehtet#567 (comment)

  • If you enable both gnirehtet and mobile data, given that gnirehtet acts as VPN, it should do all the data transfers via the VPN (gnirehtet) and not use mobile data. However, you'd have to remember to turn off mobile data when you disconnect from computer too, or Android apps will fallback to mobile data and use that.
  • another suggested workaround is to (in addition to gnirehtet) also enable bluetooth tethering with any other android device (that tethering doesn't need to work), it should supposedly also detect that bluetooth tethering as "being online", but actually use gnirehtet VPN for Internet connection. Advantage is that avoid accidental data usage, but disadvantage is that you also have to have bluetooth-tethering capable device around...

Does those work?

@westnordost
Copy link
Member

What is the use case for this? I.e. why would it be important (for you) that it worked in StreetComplete?

@mnalis
Copy link
Member

mnalis commented Dec 18, 2024

What is the use case for this? I.e. why would it be important (for you) that it worked in StreetComplete?

Don't know about @alberic89 (they'll provide their own use case), but if:

  • I only had Internet on the computer (e.g. no wifi but only Ethernet cable1), and
  • I could only get Internet on the phone via reverse tethering from said computer, and
  • I'd like use StreetComplete

then I'd need some way to download/upload quests/map data; which is only possible via in-app download/upload -- which currently doesn't work, thus this issue.

Only universal workaround currently seems to be to fork SC and do custom builds with removed checks (or buy an Ethernet switch, USB Ethernet adapter & USB-on-the-go cable for that example situation above). Both workarounds are of course highly inconvenient, costly, or both. I can see why one would prefer to be able to just use regular SC...

Footnotes

  1. or any of the dozen other possibilities which might lead to Internet being only present on the desktop/laptop computer but not on the phone, like: WiFi requiring too new standards (6Ghz for example) and phone not being the newest model, or only Internet access being via company VPN on the desktop and no client / config available for mobile (or it is available but can't be using multiple connections), WiFi having MAC authorization limits, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug feedback required more info is needed, issue will be likely closed if it is not provided
Projects
None yet
Development

No branches or pull requests

8 participants