Commit Graph

211 Commits

Author SHA1 Message Date
Tobias Brunner 2f1bf11dca android: Add a button to install user certificates
Newer Android versions don't provide this option anymore on the
selection dialog.
2021-07-14 09:59:02 +02:00
Tobias Brunner b3cdbe6693 android: Replace deprecated Switch with SwitchCompat 2021-07-14 09:59:02 +02:00
Tobias Brunner 26354d0aba android: Replace deprecated AsyncTask instances
As suggested by the Android docs, we use a global thread pool and handler
to avoid recreating them repeatedly.  Four threads should be more than
enough as we only use this to load CA certificates when the app starts
initially and to load user certs when editing a profile.
2021-07-14 09:59:02 +02:00
Tobias Brunner a8cc146240 android: Migrate from deprecated ViewPager to ViewPager2 for CA cert lists 2021-07-13 14:26:38 +02:00
Tobias Brunner c976165533 android: Replace deprecated FileObserver() constructor with newer SDKs 2021-07-13 14:25:46 +02:00
Tobias Brunner dc351a30e1 android: Replace usage of deprecated Handler() constructor 2021-07-13 14:25:46 +02:00
Tobias Brunner 93c494e295 android: Replace deprecated onActivityCreated() with onViewCreated() 2021-07-13 14:25:46 +02:00
Tobias Brunner 7cd50aeb64 android: Replace deprecated startActivityForResult/onActivityResult usage 2021-07-13 14:25:44 +02:00
Tobias Brunner f6aafb3005 Fixed some typos, courtesy of codespell
Main change is the conversion from the British cancelling/-ed to the
American canceling/-ed.
2021-06-25 11:32:29 +02:00
Tobias Brunner 6405653da2 android: Avoid lint errors when determining column indices
The lint version used on our GitHub build hosts reported these errors:

Error: Value must be ≥ 0 [Range]
        db.update(TABLE_VPNPROFILE, values, KEY_ID + " = " + cursor.getLong(cursor.getColumnIndex(KEY_ID)), null);

That's because get*() expect a valid index >= 0 but getColumnIndex()
can return -1 if the column name doesn't exist.
2021-05-05 16:40:14 +02:00
Tobias Brunner b32a9be419 android: Don't default to marking VPN connections as metered
For apps targeting Android 10, where a method to change this was added, the
default changed so that all VPN connections are marked as metered.  This means
certain background operations (e.g. syncing data) are not performed anymore
even when connected to a WiFi.  By setting this to false, the metered state
of the VPN connection reflects that of the underlying networks.
2020-12-01 16:00:09 +01:00
Tobias Brunner ec317c29ca android: Throw an exception if UUID can't get parsed
The parser is quite picky and e.g. doesn't accept UUIDs without dashes.
Even without a specific error, this at least points the users into the
right direction.

Fixes #3583.
2020-10-29 10:57:07 +01:00
Tobias Brunner 80337f4f9d android: Prevent illegalStateException when showing power whitelist dialog
If the activity is not active when the service connection is
established and handleIntent() is called, the activity's state is already
saved and any fragment transaction would result in an illegalStateException
due to state loss.  We just ignore this and wait for another initiation
attempt (via onNewIntent()).
2020-10-29 10:22:52 +01:00
Tobias Brunner 264435f626 android: Handle restarts of control activity with power whitelist dialog better
With the flag set, we basically ignore the resent intent, which is not
ideal if we have not yet actually started another activity.  The information
dialog we show first would disappear when closing and reopening the app
or even just rotating it (we hide all dialogs when receiving an intent),
but since the flag was restored, the dialog was not shown again even
when attempting to start other connections.
2020-10-29 10:22:52 +01:00
Tobias Brunner 21476a8d91 android: Make IPv6 transport flag configurable in the GUI 2020-10-29 10:22:52 +01:00
Tobias Brunner 7d10095123 android: Import IPv6 transport flag 2020-10-29 10:22:52 +01:00
Tobias Brunner 3581914387 android: Add flag to enable IPv6 transport addresses 2020-10-29 10:22:51 +01:00
Tobias Brunner 1c82e65cbe android: Ignore deprecation warning for legacy code in NetworkManager 2020-10-29 10:22:51 +01:00
Tobias Brunner a7713372d3 android: Replace deprecated getFragmentManager() in TNC-related Fragments 2020-10-29 10:22:51 +01:00
Tobias Brunner e106fce483 android: Consistently use PreferenceManager from AndroidX
android.preference.PreferenceManager has been deprecated.  The one from
AndroidX was already in use in some places.
2020-10-29 10:22:51 +01:00
Tobias Brunner 04f4bef235 android: Add a preference flag to ignore battery optimizations
This allows users to ignore whether the app is on the device's power
whitelist without a warning.  The flag is currently not set
automatically if the user denies the request.
2020-06-02 14:07:06 +02:00
Tobias Brunner a0d32a2d13 android: Ask user to add our app to the device's power whitelist
This is necessary so we can actually schedule events accurately in Doze
mode. Otherwise, we'd only get woken in intervals of several minutes (up to
15 according to the docs) after about an hour.
2020-06-02 14:07:06 +02:00
Tobias Brunner b7d66ae2cd android: Add Android-specific implementation of scheduler_t
This uses AlarmManager to schedule events in a way that ensures the app
is woken up (requires whitelisting when in Doze mode to be woken up at
the exact time, otherwise there are delays of up to 15 minutes).
2020-06-02 14:07:06 +02:00
Tobias Brunner 491cdd59bd android: Fix app icon on Android versions < 5.0
XML resources are apparently not supported there.  Moving the icon to
the mipmap folders should fix that.  Aliases are defined for the icons on
Android < 8.0.
2020-06-02 13:57:37 +02:00
Tobias Brunner 907a31db4c android: Again change how data source is handled in TileService
Evidently, onClick() may be called either before onStartListening() or
after onStopListening() has been called, which causes a crash when
trying to load a VpnProfile via mDataSource.

This partially reverts 3716af079e ("android: Avoid crash related to
TileService on Huawei devices").
2020-06-02 13:57:37 +02:00
Tobias Brunner 71d143149c android: Replace deprecated CONNECTIVITY_ACTION on newer Android versions
It was deprecated in API level 28, registerNetworkCallback is available
since API level 21, but ConnectivityManager got some updates with 24
(e.g. default network handling) so we start using it then.
2019-10-15 17:07:02 +02:00
Tobias Brunner 1227b43fe4 android: Don't use specific key types to select user certificates
Android 10 will honor the preselection and could, thus, hide some
installed certificates if we only pass "RSA".  The dialog will also only
be shown if there are actually certificates installed (i.e. users will
have to do that manually outside of the app or via profile import).

Fixes #3196.
2019-10-15 17:06:36 +02:00
Tobias Brunner a82673346e android: Import local identity for all authentication types 2019-10-15 17:05:56 +02:00
Tobias Brunner 698a18e7a5 android: Allow configuration of client identity for all authentication types
This replaces the drop-down box to select certificate identities with a
text field (in the advanced settings) with auto-completion for SANs
contained in the certificate.

The field is always shown and allows using an IKE identity different from
the username for EAP authentication (e.g. to configure a more complete
identity to select a specific config on the server).

Fixes #3134.
2019-10-15 17:05:56 +02:00
Tobias Brunner df0214baa6 android: Rename adapter for gateway address auto-completion 2019-10-15 12:18:45 +02:00
Tobias Brunner 999287f679 android: No auto-completion required for DNS server text box 2019-10-15 12:18:45 +02:00
Tobias Brunner 2e74fc2197 android: Add helper to read strings from text boxes 2019-10-15 12:18:45 +02:00
Tobias Brunner 54a4a3632d android: Fix deprecation warning related to FragmentPagerAdapter 2019-10-15 12:18:45 +02:00
Tobias Brunner 3716af079e android: Avoid crash related to TileService on Huawei devices
No idea when exactly this happens but on many Huawei devices (and
only on them) it seems that onStartListening is sometimes called after
onDestroy i.e. when the database was already closed.  This caused an
InvalidStateException in getProfile via updateTile when retrieving the
current profile.  It's possible that it happens during shutdown (there
have been similar reports related to TileService implementations) so
users might not even notice, but it pollutes the Play Console, so this
workaround now makes sure the database is open when updateTile is called.
2019-08-26 11:28:16 +02:00
Tobias Brunner 8af50736e1 android: Fix null pointer dereference in TextInputLayoutHelper
The AndroidX/Material version of TextInputLayout actually supports a
helper text, but it is always shown, so we continue to use our version.
2019-08-26 11:20:48 +02:00
Tobias Brunner 9a305b7cbe android: Replace deprecated Html.fromHtml with version from AndroidX 2019-08-26 11:20:48 +02:00
Tobias Brunner 3b9696fc9b android: Migrate from support libraries to AndroidX
The support libraries will not be developed further.
2019-08-26 11:20:48 +02:00
Tobias Brunner d59158df7b android: Switch to Loaders from the support library
They are officially deprecated as of API 28 (recommended replacement is
a combination of ViewModels and LiveData, maybe something to look into
later).
2019-08-26 11:20:48 +02:00
Tobias Brunner 199412a8ef android: Fix database upgrade from older versions 2019-04-16 15:08:23 +02:00
Tobias Brunner 2ef473be15 android: Use helper to parse IP addresses where appropriate 2019-03-05 19:02:05 +01:00
Tobias Brunner 7028e9d31e android: Add helper to parse IP addresses from strings
Using InetAddress.fromName() is not ideal as it might result in a DNS
resolution, which causes an exception if we do it from the main thread.
2019-03-05 18:56:09 +01:00
Tobias Brunner 8e7ad9ace8 android: Make DNS servers configurable in the GUI 2019-03-05 18:17:56 +01:00
Tobias Brunner 1a39c3d98d android: Import DNS servers 2019-03-05 17:45:48 +01:00
Tobias Brunner dd5de792cf android: Use configured custom DNS servers 2019-03-05 17:36:09 +01:00
Tobias Brunner dda8b891dc android: Add properties for DNS servers 2019-03-05 16:51:21 +01:00
Tobias Brunner 94cb3b4ddd android: Add menu option to copy a profile
Some users requests something like that to use different server IPs.
Interestingly, it's actually also possible to configure multiple
hostnames/IPs, separated by commas, as server address in the profile, which
are then tried one after another.

It's also useful when testing stuff to quickly compare the behavior with
some setting changed between two otherwise identical profiles.
2019-03-05 16:40:20 +01:00
Tobias Brunner 84ee9577e1 android: Avoid DNS leak due to blocking TUN device without DNS servers
It looks like Android 9 incorrectly continues to use the regular DNS
servers after the blocking TUN device is replaced with the actual
interface.  Setting DNS servers prevents that (since all traffic is
blocked, which ones doesn't really matter but local/loopback addresses
are rejected).
Interestingly, if the VPN server later does not assign any DNS servers, there
is no fallback to the non-VPN DNS servers for some reason (that's definitely
not as documented).  This could potentially be a problem as we don't
offer an option to configure DNS servers in the VPN profile.

Neither issue is seen on older Android versions (only tested on 7.1.1).
2018-10-17 11:56:30 +02:00
Tobias Brunner 9fb00bf89f android: Make sure we actually have a tile when updating it
Not sure when this happens exactly, in particular because the reported
stack traces look like this

java.lang.NullPointerException:
  at org.strongswan.android.ui.VpnTileService.updateTile (VpnTileService.java:220)
  at org.strongswan.android.ui.VpnTileService.onStartListening (VpnTileService.java:97)
  at android.service.quicksettings.TileService$H.handleMessage (TileService.java:407)

which violates the API documentation for getQsTile(), which states:

  This tile is only valid for updates between onStartListening() and
  onStopListening().

But apparently that's not always the case. There have been two reports
of such a crash, both on Android 8.0 and on Xiaomi Mi 5/6 devices, so
maybe it's a bug in that particular image.
2018-10-17 11:56:30 +02:00
Tobias Brunner 4bd4750131 android: Fix profile selection/edit when the device is rotated
The previous code lost track of the selected profile IDs, but the
widgets maintained their state (i.e. the list item was still selected and the
edit button still enabled).  Clicking the edit button then caused a crash when
trying to get the first item in the set.
2018-10-17 11:56:30 +02:00
Tobias Brunner 4e905b96dd android: Poll dropper TUN device for data on older Android systems
It seems that even the NIO version of read() is uninterruptible on
platforms < Android 7 (24).
2018-07-03 15:35:29 +02:00