android: add Wi-Fi auto-connect feature#813
Open
achanu wants to merge 1 commit into
Open
Conversation
0af82dc to
0fb3fc5
Compare
Adds per-SSID VPN control with three modes: - Whitelist (safe networks): VPN stops automatically on join, restarts on leave if unknown-network auto-start is enabled - Blacklist (unsafe networks): VPN starts automatically on join, stops on leave - Default-on: VPN starts on any network not in either list New screen under Settings → Wi-Fi auto-connect lets users manage both lists and toggle default-on. Location permission is requested to pre-fill the current SSID in the add-network dialog. Requires ACCESS_FINE_LOCATION for SSID detection on Android < 12. On API 29+ the SSID is read from NetworkCapabilities.transportInfo without a location permission prompt. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
0fb3fc5 to
e0145bc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements automatic VPN control based on Wi-Fi network name (SSID), accessible from Settings → Wi-Fi auto-connect.
Three-tier behavior:
User manual overrides are respected per-session (suppress auto-action until next reconnect).
Implementation
NetworkChangeCallback.kt: secondNetworkCallbackregistration monitors WiFi; whitelist/blacklist/defaultOn logic inonCapabilitiesChangedandonLostApp.kt:getWhitelistSsids(),getBlacklistSsids(),getWifiAutoConnectDefaultOn()backed bySharedPreferences("unencrypted")MainViewModel.kt:userStoppedVpn()/userStartedVpn()latches wired to manual toggleWifiAutoConnectView.kt+WifiAutoConnectViewModel.kt: new Compose screen with two SSID lists and a toggleAndroidManifest.xml:ACCESS_FINE_LOCATIONfor SSID access on Android < 12 viaWifiManagerfallback (runtime request included in UI)SSID reading uses
NetworkCapabilities.getTransportInfo() as? WifiInfo(available API 29+; no location permission required on API 31+ per Android 12 docs) withWifiManager.connectionInfofallback for older APIs or when transport info is redacted.Test plan
🤖 Generated with Claude Code