Commit Graph

16680 Commits

Author SHA1 Message Date
Tobias Brunner 9e05f219fd android: Use ListView for log messages
This is hopefully a bit more efficient for large log files than the previous
single TextView.  The ListView widget also provides an auto-scroll mechanism.
2018-07-03 11:31:44 +02:00
Tobias Brunner 3f71118b08 android: Simplify error handling in VPN state fragment
Always reset the error state when disconnecting via state service. This
way the error state is also cleared when the connection is terminated
directly via control activity.
2018-07-03 11:31:44 +02:00
Tobias Brunner 00a9ff4085 android: Remove MIME type filter when importing trusted certificates
This way we should see files even if the MIME type has not been set
correctly while downloading it.
2018-07-03 11:31:44 +02:00
Tobias Brunner 27cf3e666e android: Show date/thread prefix in log view if we have enough space
This is the case for tablets or even phones in landscape orientation.
600dp is the breaking point for small tablets according to Google's
docs.
2018-07-03 11:31:44 +02:00
Tobias Brunner 19c95c9bc4 android: Change log message when initializing the native code and add a divider
We don't really start a daemon and the divider should make it easier to
identify retries.
2018-07-03 11:31:44 +02:00
Tobias Brunner ef0f0cc839 android: Don't use infinite keying tries on Android 5+
This way we get some feedback about the issue in the GUI (otherwise it
would just switch to connecting state) and also some delays between retries.
2018-07-03 11:31:43 +02:00
Tobias Brunner a2b3122865 android: Allow explicit termination of a profile without confirmation 2018-07-03 11:31:43 +02:00
Tobias Brunner baf2f47413 android: Handle restarts of the control Activity better
For instance, rotating a device will restart it and this previously
could have started the wrong profile or shown the system's VPN
confirmation dialog twice.
2018-07-03 11:31:43 +02:00
Tobias Brunner 4db3bf0cb0 android: Properly handle pressing home when VPN confirmation dialog is shown
As documented, onActivityResult() is called right before onResume() when
the activity is reactivated.  However, if the system's VPN confirmation
dialog is shown and the home button is pressed, the activity is stopped
and not just paused, so its state is saved.  And onActivityResult() is
actually also called before onStart().  This means that no fragment
transactions may be committed (i.e. no dialog may be shown) when the
activity is later restarted (e.g. because there is another attempt to
connect the VPN) until onStart() has been called.  So if we'd try to show
the error dialog in onActivityResult() after returning to the launcher
it would result in an IllegalStateException.

However, showing the dialog for the previous confirmation dialog is not
ideal anyway, so we just ignore that result.
2018-07-03 11:31:43 +02:00
Tobias Brunner b1b626a1e3 android: Crudely catch exception if no file browser is available
Seen on Android TV in the emulator.
2018-07-03 11:31:43 +02:00
Tobias Brunner 064c97afae android: Enable the eap-ttls and eap-peap plugins 2018-07-03 11:31:43 +02:00
Tobias Brunner 6f9b96acb4 android: Pass UUID to VPN service to initiate profiles 2018-07-03 11:31:42 +02:00
Tobias Brunner 163f752022 android: Remove Suite B ESP proposals and reorder some algorithms 2018-07-03 11:31:42 +02:00
Tobias Brunner 058fe95339 android: Make RSA/PSS flag configurable in the GUI 2018-07-03 11:31:42 +02:00
Tobias Brunner 079094df18 android: Import RSA/PSS flag 2018-07-03 11:31:42 +02:00
Tobias Brunner 205ec47ddb android: Add flag to enable RSA/PSS 2018-07-03 11:31:42 +02:00
Tobias Brunner ad2d20e5f0 android: Make fetching OCSP/CRL interruptible
This allows cancelling connecting if e.g. the OCSP server is not
reachable. Previously this caused some delay in disconnecting state but
even worse it cause an ANR if the user tried reconnecting during that
time as the main thread would get struck in setNextProfile() (we could
probably find a better solution there too in the future).
2018-07-03 11:31:41 +02:00
Tobias Brunner 8a09350f9f android: Make CRL/OCSP/strict flags configurable in the GUI 2018-07-03 11:31:41 +02:00
Tobias Brunner e1e6096b31 android: Import CRL/OCSP/strict flags 2018-07-03 11:31:41 +02:00
Tobias Brunner 81bace09a4 android: Fix import of certificate request flag 2018-07-03 11:31:40 +02:00
Tobias Brunner a706058118 android: Add flags to control CRL/OCSP fetching and strict revocation 2018-07-03 11:31:40 +02:00
Tobias Brunner 0e2a6c46e9 revocation: Support en-/disabling CRL/OCSP at runtime 2018-07-03 11:31:40 +02:00
Tobias Brunner 3eda52f039 android: Use activity when reconnecting without (or a possibly wrong) password 2018-07-03 11:31:40 +02:00
Tobias Brunner 5bdb800abf android: Use startForegroundService() to start VpnService
This gives us some time to call startForeground() so we don't get
terminated.
2018-07-03 11:31:40 +02:00
Tobias Brunner fe1f143277 android: Install a blocking TUN device until the VPN is established
It's reinstalled when reconnecting (or during error recovery) and
eventually uninstalled after disconnecting.

Only on Android 5+, otherwise we'd block our fetcher (and Android 4.4 is
stupid in regards to overlapping TUN devices anyway).

Note that Android 8's blocking feature blocks everything that passes by
the VPN, so this only works when tunneling everything (i.e. neither subnets,
nor apps can be excluded from the VPN if that feature is enabled).
2018-07-03 11:31:39 +02:00
Tobias Brunner 99cc2d82d4 android: Exclude our own app from the VPN
Otherwise, a blocking VPN interface would prevent our fetcher from working
as we currently rely on an interface that doesn't allow access to the
underlying socket/FD, which would be required to call VpnService.protect().
2018-07-03 11:31:39 +02:00
Tobias Brunner fb3772ec95 android: Log retries to the same log file
It's cleared when a new connection is started or there is a manual
retry.
2018-07-03 11:31:39 +02:00
Tobias Brunner 1350ee1ec7 android: Use capped exponential backoff for automatic retries 2018-07-03 11:31:39 +02:00
Tobias Brunner 2ec6ad71d3 android: Show countdown and retry button in notification 2018-07-03 11:31:39 +02:00
Tobias Brunner 0d9dd4b150 android: Avoid IllegalStateException in state fragments
This happened if the state service got connected while such a fragment was
not visible (anymore or at all).
2018-07-03 11:31:38 +02:00
Tobias Brunner bc52868173 android: Don't hide the notification if we are connecting to a profile
In particular, if we are reconnecting after an error.
2018-07-03 11:31:38 +02:00
Tobias Brunner 68afdd3464 android: Add an automatic reconnect on errors
This way the connection will be attempted to be kept up even on "fatal"
errors like authentication failures.
2018-07-03 11:31:38 +02:00
Tobias Brunner 89a88d7c56 ike-sa-manager: Fix races when changing initiator SPI of an IKE_SA
Removing and readding the entry to a potentially different row/segment,
while driving out waiting and new threads, could prevent threads from
acquiring the SA even if they were waiting to check it out by unique
ID (which doesn't change), or if they were just trying to enumerate it.
With this change the row and segment doesn't change anymore and waiting
threads may acquire the SA. However, those looking for an IKE_SA by SPIs
might get one back that has a different SPI (but that's probably not
something that happens very often this early).

This was noticed because we check out SAs by unique ID in the Android
app to terminate them after failed retransmits if we are not reestablishing
the SA (otherwise we continue), and this sometimes failed.

Fixes: eaedcf8c00 ("ike-sa-manager: Add method to change the initiator SPI of an IKE_SA")
2018-07-03 11:31:38 +02:00
Tobias Brunner f23b107857 android: Show a retry button in the error banner
The button to view the log is now below the status info.  And since the
IMC results are just below that we don't need a special handling for
that anymore.
2018-07-03 11:31:38 +02:00
Tobias Brunner 063230c27b android: Add function to quickly reconnect the current profile 2018-07-03 11:31:37 +02:00
Tobias Brunner a5f565646a android: Use Java 8 features 2018-07-03 11:31:37 +02:00
Tobias Brunner ab5dbbc4ab android: Show an error if client certificate is unavailable
This can happen on systems (e.g. Android 7.x) where Always-on VPNs are
triggered right after booting before the KeyChain is unlocked by the user.
Retrieving the certificate chain or private key then fails with
"KeyChainException: IllegalStateException: keystore is LOCKED" until the
user unlocks the screen once.

The built-in client actually also fails in this situation (e.g. with XAuth
RSA), it tries three times then stops and shows an error notification.
2018-07-03 11:31:37 +02:00
Tobias Brunner f0b3e303c4 android: Show an error if a profile without a password is initiated
This could happen if an incomplete profile is used with Always-on VPN.
2018-07-03 11:31:37 +02:00
Tobias Brunner e145a5e66d android: Use modern shortcuts on Android 8+ 2018-07-03 11:31:37 +02:00
Tobias Brunner 5b6a0a3f9e android: Add an adaptive launcher icon
Using <inset> in a mipmap folder apparently is not fully valid, at least
Android Studio complains about it (it seems to work fine, though).
2018-07-03 11:31:36 +02:00
Tobias Brunner a7d679ff1b android: Show the actual error description in the notification 2018-07-03 11:31:36 +02:00
Tobias Brunner c353734f47 android: Change format for error strings
Place the dot in the main message not the descriptions of the individual
errors.
2018-07-03 11:31:36 +02:00
Tobias Brunner 4dbe7ffa3e android: Collapse Quick Settings drawer if password entry is required 2018-07-03 11:31:36 +02:00
Tobias Brunner 56f599560c android: Initiate configured default profile when triggered as Always-on VPN
With Android 8.1 this isn't triggered after a reboot until the device
has been unlocked once (solving the issue with the key store) and traffic
may optionally be blocked by the user until the VPN is established.

There are still some issues (e.g. password prompts and fatal errors), and we
might need some workaround for older Android releases.
2018-07-03 11:31:36 +02:00
Tobias Brunner d56f1bf832 android: Just reconnect if the tile is clicked even if there was an error
A long press click on the tile (or a click on the notification) will open
the main activity if more information about the error are necessary.
2018-07-03 11:31:35 +02:00
Tobias Brunner be89310784 android: Allow reconnecting without confirmation in case of an error 2018-07-03 11:31:35 +02:00
Tobias Brunner 6987ddb313 android: Show connection errors as banner, not as modal dialog 2018-07-03 11:31:35 +02:00
Tobias Brunner 64b7a6d622 android: Add Quick Settings tile to toggle VPN state
Only if there is no currently active (or previously active) profile does
this currently operate on the configured (or stored most recently used)
profile.  This way it's possible to use a different connection and
quickly disable and re-enable it again.  When unlocked the profile name
is shown, when locked a generic text is used (this detection doesn't seem
to work 100% reliably).  To disconnect, the user is forced to unlock the
device, connecting is possible without, if the credentials are available
and no fatal error occurs (it even works with the system credential store,
at least on Android 8.1).

Note that the tile is not available right after a reboot.  It seems that
the system has to be unlocked once to activate third-party tiles (will
be interesting to see how this works together with Always-on VPN).
2018-07-03 11:31:35 +02:00
Tobias Brunner 08c79d5112 android: Store the ID of the most recently used profile as preference 2018-07-03 11:31:35 +02:00
Tobias Brunner acdac14818 android: Add settings activity and default profile selection
The default profile can then be used for a Quick Settings tile or the
Always-on VPN feature.
2018-07-03 11:31:34 +02:00