Skip to content

Register the kindness network callback per the Wi-Fi pref - #1805

Merged
bitmold merged 1 commit into
guardianproject:masterfrom
munzzyy:kindness-callback-respects-wifi-pref
Sep 13, 2026
Merged

bitmold merged 1 commit into
guardianproject:masterfrom
munzzyy:kindness-callback-respects-wifi-pref

Conversation

@munzzyy

@munzzyy munzzyy commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Follow-up to 98a0cf3 (#1798). Filtering the network callback to TRANSPORT_WIFI fixed Wi-Fi being ignored while tor's VPN is active, but the "only when on Wi-Fi" switch in the kindness config sheet is still there and can be turned off. With it off:

  • on a cellular-only connection, onAvailable never fires (the request only matches Wi-Fi networks), so network events never start the proxy and the notification sits at "starting"
  • when Wi-Fi drops while cellular stays up, onLost stops the proxy and no event restarts it until Wi-Fi comes back

The limitSnowflakeProxyingWifi() && !hasWifi check in onAvailable also can't do anything under the filter, since every network it sees is Wi-Fi.

This keeps the Wi-Fi-filtered registration when the pref is on, so the VPN fix stays, and goes back to registerDefaultNetworkCallback when it's off, the single-tracked-network behavior this handler was written for. The service restarts when the config sheet changes a setting (the KEY_CONFIG_CHANGED listener in KindnessFragment double-toggles the switch), so the registration always matches the pref. onDestroy's unregisterNetworkCallback covers both registration paths.

Compiles and the unit tests pass. I don't have a cellular device to hand, so a quick check on hardware with the Wi-Fi switch off would be a good sanity pass.

98a0cf3 filtered the callback to TRANSPORT_WIFI so a running tor
VPN can't hide Wi-Fi from Kindness Mode. But the "only when on Wi-Fi"
switch in the kindness config sheet can still be turned off, and with
it off the Wi-Fi filter is wrong: on a cellular-only connection
onAvailable never fires, so network events never start the proxy, and
when Wi-Fi drops while cellular stays up, onLost stops the proxy and
nothing restarts it until Wi-Fi comes back.

Keep the Wi-Fi-filtered registration when the pref is on, and register
the default network callback like before when it's off. The service is
restarted when the config sheet changes a setting, so the registration
always matches the pref.
@bitmold bitmold self-assigned this Sep 13, 2026
@bitmold bitmold added the snowlfake proxy AKA kindness mode - using Orbot to help others connect to Tor Network via Snowflake Bridges label Sep 13, 2026
@bitmold

bitmold commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator

I will look into this soon, thank you

@bitmold

bitmold commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator

This looks good with my testing. I don't like how which callback is used is tied to reading a value in the Service's onCreate().

Like you said,:

This keeps the Wi-Fi-filtered registration when the pref is on, so the VPN fix stays, and goes back to registerDefaultNetworkCallback when it's off, the single-tracked-network behavior this handler was written for. The service restarts when the config sheet changes a setting (the KEY_CONFIG_CHANGED listener in KindnessFragment double-toggles the switch), so the registration always matches the pref. onDestroy's unregisterNetworkCallback covers both registration paths.

I don't like how switching that preference switch (for limiting to WiFi only) restarts the Service and allows the onCreate() logic you fixed here to work. In an ideal world, these things (the UI, the service, preference changes) wouldn't all be so tightly coupled.

Anyway, thank you for this work. This is a big big help.

@munzzyy

munzzyy commented Sep 13, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for merging it. Agreed on the coupling. Reading the pref in onCreate and relying on the service restart to re-register works with the existing wiring rather than fixing it. The cleaner path is reacting to the pref change directly instead of bouncing the whole service, but that is a bigger change than this bug needed. I am happy to take a run at decoupling it as a follow-up if you think it is worth doing.

bitmold added a commit to munzzyy/orbot-android that referenced this pull request Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

snowlfake proxy AKA kindness mode - using Orbot to help others connect to Tor Network via Snowflake Bridges

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants