Skip to content

Commit

Permalink
android: start VPN after preparing VPN
Browse files Browse the repository at this point in the history
#398 introduced a bug where we were not calling startVPN after getting (or confirming) VPN.prepare permissions
This resulted in the VPN not being turned on after logging in for the first time

Updates tailscale/tailscale#12148

Signed-off-by: kari-ts <kari@tailscale.com>
  • Loading branch information
kari-ts committed May 28, 2024
1 parent 75db9e6 commit 39c0cb3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion android/src/main/java/com/tailscale/ipn/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,13 @@ class MainActivity : ComponentActivity() {
if (granted) {
Log.d("VpnPermission", "VPN permission granted")
viewModel.setVpnPrepared(true)
App.get().startVPN()
} else {
Log.d("VpnPermission", "VPN permission denied")
viewModel.setVpnPrepared(false)
}
}
viewModel.setVpnPermissionLauncher(vpnPermissionLauncher)
viewModel.setVpnPermissionLauncher(vpnPermissionLauncher)

setContent {
AppTheme {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class MainViewModel : IpnViewModel() {
vpnPermissionLauncher?.launch(vpnIntent)
} else {
setVpnPrepared(true)
startVPN()
}
}

Expand All @@ -119,7 +120,6 @@ class MainViewModel : IpnViewModel() {
when {
!isPrepared -> showVPNPermissionLauncherIfUnauthorized()
state == Ipn.State.Running -> stopVPN()
else -> startVPN()
}
}

Expand Down

0 comments on commit 39c0cb3

Please sign in to comment.