Skip to content

Commit 211eb45

Browse files
authored
android: add fallback VPN permission (#662)
Some heavily customized OEMS may auto-deny VPN requests without exposing the setting. Show a fallback dialog for devices with no visible VPN panel. Updates tailscale/tailscale#14095 Signed-off-by: kari-ts <[email protected]>
1 parent 28084cb commit 211eb45

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

android/src/main/java/com/tailscale/ipn/MainActivity.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,15 @@ class MainActivity : ComponentActivity() {
154154
} else {
155155
TSLog.d("VpnPermission", "Permission was denied by the user")
156156
vpnViewModel.setVpnPrepared(false)
157+
158+
AlertDialog.Builder(this)
159+
.setTitle(R.string.vpn_permission_needed)
160+
.setMessage(R.string.vpn_explainer)
161+
.setPositiveButton(R.string.try_again) { _, _ ->
162+
viewModel.showVPNPermissionLauncherIfUnauthorized()
163+
}
164+
.setNegativeButton(R.string.cancel, null)
165+
.show()
157166
}
158167
}
159168
}

android/src/main/java/com/tailscale/ipn/ui/viewModel/MainViewModel.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ class MainViewModel(private val vpnViewModel: VpnViewModel) : IpnViewModel() {
203203

204204
fun showVPNPermissionLauncherIfUnauthorized() {
205205
val vpnIntent = VpnService.prepare(App.get())
206+
TSLog.d("VpnPermissions", "vpnIntent=$vpnIntent")
206207
if (vpnIntent != null) {
207208
vpnPermissionLauncher?.launch(vpnIntent)
208209
} else {

android/src/main/res/values/strings.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
<string name="clear_search">Clear search</string>
2727
<string name="off">Off</string>
2828
<string name="on">On</string>
29+
<string name="try_again">Try again</string>
30+
<string name="cancel">Cancel</string>
2931

3032
<!-- Strings for the about screen -->
3133
<string name="app_name" translatable="false">Tailscale</string>
@@ -314,7 +316,6 @@
314316
<string name="vpn_permission_denied">VPN permission denied</string>
315317
<string name="multiple_vpn_explainer">Only one VPN can be active, and it appears another is already running. Before starting Tailscale, disable the other VPN.</string>
316318
<string name="go_to_settings">Go to Settings</string>
317-
<string name="cancel">Cancel</string>
318319
<string name="subnet_routes">Subnet routes</string>
319320
<string name="run_as_subnet_router_header">Advertise routes to machines that are not running Tailscale to make them available in your tailnet. Routes must be approved in the admin console.</string>
320321
<string name="open_kb_article">Open KB Article</string>
@@ -334,6 +335,10 @@
334335
<string name="hostname">Hostname</string>
335336
<string name="failed_to_save">Failed to save</string>
336337

338+
<!-- Strings for fallback VPN dialog -->
339+
<string name="vpn_permission_needed">VPN permission needed</string>
340+
<string name="vpn_explainer">Tailscale needs VPN access, but it looks like your device may not show VPN settings. If you are using another VPN app or have work policies, disable them first, then try again.</string>
341+
337342
<!-- Strings for the taildrop directory picker interstitial -->
338343
<string name="taildrop_directory_picker_title">Taildrop Directory</string>
339344
<string name="taildrop_directory_picker_body">You have not selected a directory for incoming taildrop transfers. Please select or create a target directory.</string>

0 commit comments

Comments
 (0)