ui: do not crash if tunnel preparation fails
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
59da677c23
commit
9fa8ca8c77
@ -67,6 +67,7 @@ abstract class BaseFragment : Fragment(), OnSelectedTunnelChangedListener {
|
||||
val activity = activity ?: return
|
||||
activity.lifecycleScope.launch {
|
||||
if (Application.getBackend() is GoBackend) {
|
||||
try {
|
||||
val intent = GoBackend.VpnService.prepare(activity)
|
||||
if (intent != null) {
|
||||
pendingTunnel = tunnel
|
||||
@ -74,6 +75,13 @@ abstract class BaseFragment : Fragment(), OnSelectedTunnelChangedListener {
|
||||
permissionActivityResultLauncher.launch(intent)
|
||||
return@launch
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
val message = activity.getString(R.string.error_prepare, ErrorMessages[e])
|
||||
Snackbar.make(view, message, Snackbar.LENGTH_LONG)
|
||||
.setAnchorView(view.findViewById(R.id.create_fab))
|
||||
.show()
|
||||
Log.e(TAG, message, e)
|
||||
}
|
||||
}
|
||||
setTunnelStateWithPermissionsResult(tunnel, checked)
|
||||
}
|
||||
|
@ -120,6 +120,7 @@
|
||||
<string name="error_down">Error bringing down tunnel: %s</string>
|
||||
<string name="error_fetching_apps">Error fetching apps list: %s</string>
|
||||
<string name="error_root">Please obtain root access and try again</string>
|
||||
<string name="error_prepare">Error preparing tunnel: %s</string>
|
||||
<string name="error_up">Error bringing up tunnel: %s</string>
|
||||
<string name="exclude_private_ips">Exclude private IPs</string>
|
||||
<string name="generate_new_private_key">Generate new private key</string>
|
||||
|
Loading…
Reference in New Issue
Block a user