android: start VPN after preparing VPN (#412)

https://github.com/tailscale/tailscale-android/pull/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>
pull/413/head
kari-ts 6 months ago committed by GitHub
parent 0df6c61eee
commit a6fd8a8093
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -117,6 +117,7 @@ class MainActivity : ComponentActivity() {
if (granted) { if (granted) {
Log.d("VpnPermission", "VPN permission granted") Log.d("VpnPermission", "VPN permission granted")
viewModel.setVpnPrepared(true) viewModel.setVpnPrepared(true)
App.get().startVPN()
} else { } else {
Log.d("VpnPermission", "VPN permission denied") Log.d("VpnPermission", "VPN permission denied")
viewModel.setVpnPrepared(false) viewModel.setVpnPrepared(false)

@ -109,7 +109,7 @@ fun MainView(
Column( Column(
modifier = Modifier.fillMaxWidth().padding(paddingInsets), modifier = Modifier.fillMaxWidth().padding(paddingInsets),
verticalArrangement = Arrangement.Center) { verticalArrangement = Arrangement.Center) {
// Assume VPN has been prepared. Whether or not it has been prepared cannot be known // Assume VPN has been prepared for optimistic UI. Whether or not it has been prepared cannot be known
// until permission has been granted to prepare the VPN. // until permission has been granted to prepare the VPN.
val isPrepared by viewModel.vpnPrepared.collectAsState(initial = true) val isPrepared by viewModel.vpnPrepared.collectAsState(initial = true)
val isOn by viewModel.vpnToggleState.collectAsState(initial = false) val isOn by viewModel.vpnToggleState.collectAsState(initial = false)
@ -170,6 +170,8 @@ fun MainView(
PromptPermissionsIfNecessary() PromptPermissionsIfNecessary()
viewModel.showVPNPermissionLauncherIfUnauthorized()
if (showKeyExpiry) { if (showKeyExpiry) {
ExpiryNotification(netmap = netmap, action = { viewModel.login() }) ExpiryNotification(netmap = netmap, action = { viewModel.login() })
} }

@ -109,6 +109,7 @@ class MainViewModel : IpnViewModel() {
vpnPermissionLauncher?.launch(vpnIntent) vpnPermissionLauncher?.launch(vpnIntent)
} else { } else {
setVpnPrepared(true) setVpnPrepared(true)
startVPN()
} }
} }

Loading…
Cancel
Save