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 3 weeks ago committed by GitHub
parent 0df6c61eee
commit a6fd8a8093
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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 {

@ -109,7 +109,7 @@ fun MainView(
Column(
modifier = Modifier.fillMaxWidth().padding(paddingInsets),
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.
val isPrepared by viewModel.vpnPrepared.collectAsState(initial = true)
val isOn by viewModel.vpnToggleState.collectAsState(initial = false)
@ -170,6 +170,8 @@ fun MainView(
PromptPermissionsIfNecessary()
viewModel.showVPNPermissionLauncherIfUnauthorized()
if (showKeyExpiry) {
ExpiryNotification(netmap = netmap, action = { viewModel.login() })
}

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

Loading…
Cancel
Save