Commit Graph

617 Commits

Author SHA1 Message Date
Jason A. Donenfeld
a42892bc28 TunnelEditorFragment: do not pass null localConfig
Otherwise we might dereference it, per this play store gathered trace:

Xiaomi Redmi 3S (land), 2048MB RAM, Android 7.1
java.lang.NullPointerException:
at com.wireguard.android.model.Tunnel.setConfig (Tunnel.java:118)
at com.wireguard.android.fragment.TunnelEditorFragment.onOptionsItemSelected (TunnelEditorFragment.java:160)
at android.app.Fragment.performOptionsItemSelected (Fragment.java:2478)
at android.app.FragmentManagerImpl.dispatchOptionsItemSelected (FragmentManager.java:2182)
at android.app.FragmentController.dispatchOptionsItemSelected (FragmentController.java:336)
at android.app.Activity.onMenuItemSelected (Activity.java:3211)
at com.android.internal.policy.PhoneWindow.onMenuItemSelected (PhoneWindow.java:1219)
at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected (MenuBuilder.java:761)
at com.android.internal.view.menu.MenuItemImpl.invoke (MenuItemImpl.java:152)
at com.android.internal.view.menu.MenuBuilder.performItemAction (MenuBuilder.java:904)
at com.android.internal.view.menu.MenuBuilder.performItemAction (MenuBuilder.java:894)
at android.widget.ActionMenuView.invokeItem (ActionMenuView.java:616)
at com.android.internal.view.menu.ActionMenuItemView.onClick (ActionMenuItemView.java:152)
at android.view.View.performClick (View.java:5637)
at android.view.View$PerformClick.run (View.java:22433)
at android.os.Handler.handleCallback (Handler.java:751)
at android.os.Handler.dispatchMessage (Handler.java:95)
at android.os.Looper.loop (Looper.java:153)
at android.app.ActivityThread.main (ActivityThread.java:6244)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:891)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:781)

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-01-10 00:54:59 +01:00
Jason A. Donenfeld
138ba5c416 QuickTileService: sometimes tile is null
According to play store reports, such as:

wt88047, 0MB RAM, Android 8.1
java.lang.NullPointerException:
at com.wireguard.android.QuickTileService.updateTile (QuickTileService.java:97)
at com.wireguard.android.QuickTileService.onStartListening (QuickTileService.java:56)
at android.service.quicksettings.TileService$H.handleMessage (TileService.java:407)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loop (Looper.java:164)
at android.app.ActivityThread.main (ActivityThread.java:6520)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:442)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:807)

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-01-10 00:41:28 +01:00
Samuel Holland
c6bdeb1d45 Prepare version 0.3.0
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-09 10:31:08 -06:00
Samuel Holland
17f8c65b2e WgQuickBackend: Finish the implementation
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-09 10:31:08 -06:00
Samuel Holland
933a685585 model: Chain completions to avoid race conditions
Otherwise getConfigAsync().thenCompose(x -> setState()) would be unsafe.

This reverts commit a6595a273afd50524cc66765c6bfbdcc34cb12e4.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-01-09 10:03:29 -06:00
Samuel Holland
daacc06a0d global: Clean up error logging
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-09 09:37:49 -06:00
Samuel Holland
a1d955ef62 WgQuickBackend: Log when tunnels can't be enumerated
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-09 09:18:03 -06:00
Samuel Holland
ca077dd090 RootShell: Improve shell start error handling
No need to catch and re-throw exceptions before starting the process. If
running `su` itself fails, there's no (functional) root, so report that.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-09 09:17:08 -06:00
Samuel Holland
3d6737e32f RootShell: Be stricter about command delimiters
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-09 09:16:53 -06:00
Jason A. Donenfeld
643b698f30 RootShell: stop if we can't start
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-01-09 08:39:07 -06:00
Jason A. Donenfeld
23c09eb655 RootShell: hoist out synchronization
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-01-09 15:19:50 +01:00
Jason A. Donenfeld
14638b10ae tools: try not to overflow
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-01-09 15:15:15 +01:00
Samuel Holland
426fa7d50b ToolsInstaller: Propagate NoRootException properly
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-09 08:13:32 -06:00
Samuel Holland
52e8eef9ce RootShell: Simplify, synchronize, clean up
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-09 08:13:11 -06:00
Samuel Holland
662bc3894b TunnelListFragment: Remove useless keyword
final doesn't do anything in try-with-resources (it's always final).

Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-09 06:25:53 -06:00
Jason A. Donenfeld
1451c4baf5 ToolsInstaller: terminators are better than seperators
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-01-09 13:12:49 +01:00
Jason A. Donenfeld
2785def37a RootShell: synchronize accesses to single shell
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-01-09 13:12:49 +01:00
Samuel Holland
204755d689 RootShell: Simplify constructor
ToolsInstaller now takes care of installing the tools.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-08 23:49:14 -06:00
Samuel Holland
c806e655fa WgQuickBackend: Ensure tools are available before use
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-08 23:39:32 -06:00
Samuel Holland
5201c7f849 ToolsInstaller: Add a method to ensure tool availability
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-08 23:39:32 -06:00
Samuel Holland
ba30d46e08 WgQuickBackend: Inline resolveState()
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-08 23:39:32 -06:00
Samuel Holland
1cfb938dd1 ToolsInstaller: Add methods to check/make symlinks
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-08 23:39:32 -06:00
Samuel Holland
011d683c23 ToolsInstallerPreference: Examine current state on load
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-08 23:39:32 -06:00
Samuel Holland
b87568482d ToolsInstaller: Add method to check installation status
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-08 23:39:32 -06:00
Samuel Holland
2776455d4f TunnelEditorFragment: Fix dismissing creator activity
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-08 23:39:32 -06:00
Samuel Holland
4f02817ef0 global: Fix or suppress most lints/warnings
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-08 23:39:26 -06:00
Samuel Holland
dd69a2e778 project: Remove currently-unused library
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-08 23:39:15 -06:00
Samuel Holland
710ffc7bb3 Fragment/Tile: Make success/error messages translatable
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-08 20:30:03 -06:00
Jason A. Donenfeld
6361628e16 layout: never use suggestions
IP addresses and key material could be potentially sensitive. We also
don't want any interactions with the suggestive text APIs. So, we mark
it as both a visible password and we turn off suggestions. This will fix
the length limit, too, in Android 8.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-01-09 00:23:33 +01:00
Jason A. Donenfeld
da30a6d449 TunnelListFragment: fix plural grammar
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-01-09 00:23:22 +01:00
Jason A. Donenfeld
1ae10b8f45 RootShell: fix off by one
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-01-08 20:42:12 +01:00
Jason A. Donenfeld
5944efc13c QuickTileService: show toast for longer and use right messages
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-01-08 20:30:25 +01:00
Jason A. Donenfeld
7645ea15c4 global: Prefix tags with WireGuard/
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-01-08 20:29:51 +01:00
Jason A. Donenfeld
31ba7e6593 RootShell: multiplex commands
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-01-08 19:46:51 +01:00
Samuel Holland
ae2068dc16 Port over remaining error handling
This doesn't really belong here, but there's no sense in throwing it
away--even here, it's a minor optimization.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-08 04:34:28 -06:00
Samuel Holland
c4e91f8040 Handle tunnel state change errors appropriately
This class should probably be renamed and moved, but I don't know to
what or where.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-08 04:33:54 -06:00
Samuel Holland
c40555c1bd TunnelListFragment: Fix crash on deleting multiple tunnels
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-08 04:31:30 -06:00
Samuel Holland
b6ed17884f ToggleSwitch: Improve reliability
It's not great, but it's better than it was.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-08 04:31:04 -06:00
Samuel Holland
668d90f063 WgQuickBackend: Improve error handling
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-08 04:25:15 -06:00
Samuel Holland
ec81014c4e Tunnel: Add a State factory method
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-08 04:25:15 -06:00
Samuel Holland
d645d69847 project: Global cleanup
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-08 02:19:13 -06:00
Samuel Holland
88e30431cb Application: Remove unneeded exported component
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-08 00:35:35 -06:00
Samuel Holland
08cca56388 ToolsInstaller: Extract to its own classes
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-08 00:34:55 -06:00
Samuel Holland
1f30e133d6 TunnelManager: Simplify save/resume methods
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-07 21:52:14 -06:00
Samuel Holland
4a3d68bb7d BaseActivity: Make variable names consistent
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-07 21:51:55 -06:00
Samuel Holland
1fd9547f6a TunnelManager/QuickTileService: Remember last used tunnel
This is actually a bit simpler than having a manually-selected "primary"
tunnel, and is hopefully easier for the user.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-07 21:50:43 -06:00
Samuel Holland
38b2aafce8 Remove primary configuration preference
It is no longer used.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-07 21:46:41 -06:00
Samuel Holland
16c0b5b15a FileConfigStore: Move function returns outside try blocks
This makes more clear what things can throw exceptions, and the
functions' control flow.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-07 20:33:39 -06:00
Samuel Holland
0ab3e29432 Tunnel: Remove UNKNOWN state
It's never used.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-07 20:33:07 -06:00
Samuel Holland
11f851abf8 Move bundle keys where they are used
This both clarifies and simplifies the code.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-07 20:32:01 -06:00
Samuel Holland
cef97b990e WgQuickBackend: Prefer ArrayList over LinkedList
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-07 01:45:27 -06:00
Samuel Holland
e01813487f app: Upgrade to build tools version 27.0.3
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-07 01:33:11 -06:00
Samuel Holland
137325d3cc ConfigEditorFragment: Support renaming tunnels
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-07 01:23:08 -06:00
Samuel Holland
30396b8718 model: Allow renaming tunnels
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-07 01:22:31 -06:00
Samuel Holland
e70b242c01 model: Remove confusing uses of completion chaining
This looks like the builder pattern, but isn't.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-07 00:41:47 -06:00
Samuel Holland
77fdd7c883 TunnelListFragment: Name a CompletionStage what it is
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-07 00:26:08 -06:00
Samuel Holland
1862ff0bbe Tunnel: The name passed to isNameValid is never null
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-07 00:25:49 -06:00
Samuel Holland
2f5494d47c ConfigEditorFragment: Ensure localName is never null
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-07 00:25:33 -06:00
Samuel Holland
be8b6017d5 Make TunnelManager the point of asynchronicity
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-07 00:24:56 -06:00
Samuel Holland
5a2f692d73 TunnelManager: Sort tunnels case-insensitively
The second comparator is required to allow multiple tunnels that differ
only in case.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-06 23:45:49 -06:00
Samuel Holland
536c6958fc SortedKeyedList...: Support arbitrary comparators
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-06 23:44:34 -06:00
Samuel Holland
4f2b6bef84 Keyed...: Rename all the things
Hooray for diamond interface inheritance.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-06 23:07:17 -06:00
Samuel Holland
4d38993832 project: Minor cleanups
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-06 22:14:10 -06:00
Samuel Holland
22bdffcecd model: Proxy all async work through the TunnelManager
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-06 06:30:41 -06:00
Samuel Holland
2315a699fb TunnelManager: Enumerate running tunnels only once
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-06 05:20:11 -06:00
Samuel Holland
df7d18fb5d Tunnel: Require passing a state to the constructor
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-06 05:18:34 -06:00
Samuel Holland
1c2239ae91 Backend: Add a function to enumerate running tunnels
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-06 05:18:34 -06:00
Samuel Holland
2543f28274 MainActivity: Fix ActionBar after rotation
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-06 05:18:34 -06:00
Samuel Holland
2206dfc432 TunnelDetailFragment: Allow copying peer public keys
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-06 05:18:34 -06:00
Samuel Holland
193de10972 TunnelDetailFragment: Remove state text and last change
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-06 05:18:34 -06:00
Samuel Holland
dbed7155d6 activity: Remove useless indirection
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-06 05:18:34 -06:00
Samuel Holland
63efaa2dcc databinding: Collection classes use generic E
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-06 04:09:30 -06:00
Samuel Holland
5f09afbc16 databinding: Simplify method signature
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-06 04:09:30 -06:00
Samuel Holland
6eef4093d8 databinding: Remove unused classes and methods
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-06 04:09:30 -06:00
Samuel Holland
ff0bb081a0 Convert the list of tunnels to a KeyedObservableList
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-06 04:09:30 -06:00
Samuel Holland
c73287f64b databinding: Add an adapter for the KeyedObservableList
This adapter actually finally implements stable IDs correctly.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-06 04:09:30 -06:00
Samuel Holland
e24654ce7c util: Add a keyed list class and a sorted variant
This is inspired by C#'s KeyedCollection. The sorted variant removes the
need for an observable SortedMap.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-06 04:09:30 -06:00
Samuel Holland
58eedfd6d9 TunnelManager: Clear primary tunnel when it's removed
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-06 04:09:30 -06:00
Samuel Holland
609194fae2 Serviceless rewrite, part 1
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-06 04:09:29 -06:00
Samuel Holland
4c0869393e Rename package widgets -> widget
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-06 04:08:01 -06:00
Samuel Holland
b7196e328a Rename package bindings -> databinding
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-06 04:08:01 -06:00
Samuel Holland
7120df7a45 app: Enable Java 8 features
Signed-off-by: Samuel Holland <samuel@sholland.org>
2017-12-26 14:06:32 -06:00
Samuel Holland
e3a22e27c4 app: Upgrade to build tools 27.0.2
Signed-off-by: Samuel Holland <samuel@sholland.org>
2017-12-26 14:00:19 -06:00
Jason A. Donenfeld
2caa06d9fb wg-quick: set mtu after addresses
This has all sorts of terrible implications and fixes a problem in a
pretty terrible way. If the interface MTU is less than 1280, IPv6
addresses will fail to be added. Rather than explictly trying to catch
this and do something particular about it -- such as nicely warning the
user that there could be a v6 isolation issue, for example -- we just
set the MTU _after_ we set the addresses, so that in setting the MTU, we
wind up removing the addresses that were just added. This is pretty bad,
but it makes things a bit smoother.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-12-26 20:04:40 +01:00
Jason A. Donenfeld
53752eb21e tools: use cmp and right arguments for mount
Some systems don't have cmp.
Some systems have buggy mount tools.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-12-20 17:54:28 +01:00
Jason A. Donenfeld
8937cf82fb tools: add wg-quick directly
We also use all search paths for tool, since many want this to be CLI
too.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-12-20 05:02:51 +01:00
Jason A. Donenfeld
40198132e0 tools: force ld.gold
This is to work around a linker bug affecting the NDK.

Reference: https://github.com/android-ndk/ndk/issues/602

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-12-19 02:53:02 +01:00
Jason A. Donenfeld
9b92f4d3c5 SettingsActivity: allow for installing command line tools
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-12-19 02:42:00 +01:00
Jason A. Donenfeld
ecc2a1c759 tools: better cmake
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-12-18 04:57:40 +01:00
Jason A. Donenfeld
b7a6b44ec1 RootShell: rewrite
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-12-16 07:07:05 +01:00
Jason A. Donenfeld
6d1117a94c tools: build required tools with apk
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-12-15 06:00:45 +01:00
Jason A. Donenfeld
9e028ae8d6 VpnService: require root access
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-30 21:46:56 +01:00
Jason A. Donenfeld
417e973c8f NotSupportedActivity: fix font size
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-29 13:24:40 +01:00
Samuel Holland
97e05ff965 ConfigListFragment: Use correct icon for FAB
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-28 20:42:25 -06:00
Samuel Holland
2b88150fd8 VpnService: Avoid duplicating file check
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-28 20:42:25 -06:00
Jason A. Donenfeld
eb5fdf200a Config: use consistant verb
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-29 03:30:23 +01:00
Jason A. Donenfeld
af33378522 VpnService: search for binaries in most likely places first
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-29 03:29:36 +01:00
Samuel Holland
ee9b374d49 ConfigList: Always dismiss FAB menu on ListView touch
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-28 20:18:11 -06:00
Samuel Holland
49df1ebc40 NotSupported: Fix links
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-28 20:15:50 -06:00
Samuel Holland
8ba902ae99 build.gradle: Consistent quoting style
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-28 20:15:40 -06:00
Samuel Holland
4a672fc05d ConfigListFragment: Use a floating action menu
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-28 20:14:47 -06:00
Samuel Holland
19f0089559 Show ConfigActivity when holding QS tile
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-28 17:33:32 -06:00
Samuel Holland
312816d4fd res/drawable: Fix icon sizes
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-28 17:30:56 -06:00
Samuel Holland
74a6526695 ConfigActivity: Listen for name changes
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-28 17:25:49 -06:00
Jason A. Donenfeld
2f310f0fad EditFragment: do not autocomplete or capitalize ifnames
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-28 22:14:00 +01:00
Jason A. Donenfeld
f00622a2a9 Open: better icon
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-28 13:09:00 +01:00
Jason A. Donenfeld
bbe058418b NotSupported: Better sorry text
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-27 21:29:40 +01:00
Jason A. Donenfeld
641e45e727 SettingsActivity: directly pass through bundle
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-27 05:22:54 +01:00
Jason A. Donenfeld
2cc7f6c2ea ConfigDetailFragment: wire up toggle switch
Finally no gross colors.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-27 04:35:04 +01:00
Jason A. Donenfeld
6bc6aea2d0 NotSupported: check if the module exists
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-27 04:28:48 +01:00
Jason A. Donenfeld
ad16d2cc7b Settings: show quick tile config if no primary is defined
This seems like a horrific set of hacks.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-27 03:13:34 +01:00
Jason A. Donenfeld
b0bb46382c ConfigImporter: give updates when something goes wrong
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-27 01:28:43 +01:00
Jason A. Donenfeld
d43c87a869 QuickTileService: show app if no profiles exist
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-27 00:43:34 +01:00
Jason A. Donenfeld
e421b997cd Config: make parsing stricter
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-26 23:45:41 +01:00
Samuel Holland
14a7ada6e1 ConfigImporter: Get filename from content resolver
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-25 23:39:08 -06:00
Samuel Holland
283340f5dc ConfigList: A better toggle switch
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-25 23:05:39 -06:00
Samuel Holland
666dc25cb0 widgets: Import ToggleSwitch from the AOSP Settings app
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-25 22:17:17 -06:00
Samuel Holland
f1febcf9b6 ConfigList: Poor man's switch
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-24 23:44:18 -06:00
Samuel Holland
3233855630 BindingAdapters: Sort existing adapters
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-24 21:27:18 -06:00
Samuel Holland
50a7a12de2 VpnService: Move it to a backends package
It should be split into two pieces: configuration file management
(loading/saving/renaming/deleting) and calling into wg-quick via
RootShell. The configuration file management part should then go
back into the main package. This is in preparation for adding
additional backends based on wg(8) and wireguard-go.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-24 21:16:37 -06:00
Samuel Holland
4a98d07806 ConfigActivity: Add import menu item
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-08 00:50:24 -06:00
Samuel Holland
cd6a124c84 VpnService: Add helper for importing configs
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-08 00:49:44 -06:00
Samuel Holland
70156381a7 Bindings: Merge bugfixes and updates
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-08 00:07:29 -06:00
Samuel Holland
6231bb18ac Bindings: Move to a separate package
These are really app-independent reusable classes. Moving them to a
separate package helps avoid polluting the main app package, and makes
them easier to upgrade.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-07 23:34:22 -06:00
Samuel Holland
6945aa1107 project: Update gradle files
These are automatic changes made by Android Studio 3.0.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-07 22:52:50 -06:00
Samuel Holland
58c0b98c3f Prepare version 0.1.0
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-24 23:24:17 -05:00
Samuel Holland
b7992d234c ConfigListFragment: Prevent config names from wrapping
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-24 23:24:09 -05:00
Samuel Holland
292b16b1a1 ConfigActivity: Only use split layout on tablet-sized screens
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-24 23:22:22 -05:00
Samuel Holland
a828e83399 Centralize/unify validation of configurations
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-24 22:13:46 -05:00
Samuel Holland
23fdb72eda ConfigActivity: Invert isSplitLayout→isSingleLayout for clarity
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-24 17:25:49 -05:00
Samuel Holland
b1d0091bc0 ObservableSortedMap: Document interface
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-24 02:18:13 -05:00
Samuel Holland
3daddad573 Remove state debugging messages
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-24 02:18:05 -05:00
Samuel Holland
dcc7ddcd3b ConfigEditFragment: Copy public key on click
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-24 02:11:55 -05:00
Samuel Holland
4fdb3458ec ConfigEditFragment: Mark the persistent keepalive as optional
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-24 02:01:51 -05:00
Samuel Holland
cd868bc997 ConfigEditFragment: Add a field for the optional pre-shared key
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-24 02:01:19 -05:00
Samuel Holland
3d6109e6d9 Peer: Add a field for the optional pre-shared key
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-24 02:00:53 -05:00
Samuel Holland
881ad4fd47 ConfigActivity: Fix condition for inserting back stack entries
Fixes saved editor state on rotation (removing and recreating the editor
discarded changes).

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-24 01:47:12 -05:00
Samuel Holland
c0a76f87da ConfigActivity: Save editor state across fragment instances
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-24 01:31:19 -05:00
Samuel Holland
e446870ac1 AddActivity: Update for ConfigEditFragment changes
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-24 01:31:19 -05:00
Samuel Holland
e2df9931ac ConfigEditFragment: Save and restore editor state properly
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-24 01:31:16 -05:00
Samuel Holland
f83c84ce4e ConfigActivity: Avoid unnecessary executePendingTransactions
Nothing later tries to find the list using findFragmentById().

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-24 01:22:49 -05:00
Samuel Holland
290c98a9e3 ConfigListFragment: Avoid unnecessary findViewById
The generated ViewDataBinding has fields for each view with an id.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-24 01:22:20 -05:00
Samuel Holland
632f3f73a2 ConfigActivity: Log state transitions
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-23 23:51:08 -05:00
Samuel Holland
b2357e58e3 Config/Interface/Peer: Make Parcelable
This allows saving the editor state across restarts.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-23 23:47:44 -05:00
Samuel Holland
95384851cd Config/Interface/Peer: Fix some missed change notifications
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-23 23:43:58 -05:00
Samuel Holland
d1a5c1a72e VpnService: Fix some edge cases in ConfigUpdater
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-23 18:04:45 -05:00
Samuel Holland
0e46f95668 Config/Interface: Allow copyFrom() to work on null
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-23 18:02:37 -05:00
Samuel Holland
d3e6b311ca BaseConfigActivity: Remember editing state
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-23 18:02:16 -05:00
Samuel Holland
b1c1889c50 manifest: ConfigActivity is parent to AddActivity
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-23 17:57:43 -05:00
Samuel Holland
c1cdea42b6 Finish first pass of config editor fields
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-22 23:10:41 -05:00
Samuel Holland
3a264f7020 QuickTileService: Update the tile once on service init
This makes the tile show the correct info when it is first added.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-22 23:10:41 -05:00
Samuel Holland
353028420b Add an adapter for binding an ObservableList to a LinearLayout
EditTexts do not work in ListViews.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-22 23:10:35 -05:00
Samuel Holland
fb919a7226 Use data binding to provide EditText input filters
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-22 21:48:42 -05:00
Samuel Holland
5d04714eea ConfigAddActivity: Rename to AddActivity
Not everything needs to start with Config

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-22 01:27:29 -05:00
Samuel Holland
90cd59c866 ConfigActivity: Fix fragment state when leaving/entering app
Do this by making the fragment transition functions idempotent.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-21 21:25:31 -05:00
Samuel Holland
9026317b0e Peer: Associate with a Config
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-19 18:50:35 -05:00
Samuel Holland
fbd923a060 Minor cleanups
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-19 18:48:07 -05:00
Samuel Holland
a49fe9adf5 ObservableAdapters: notify on map/list being set
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-18 23:25:40 -05:00
Samuel Holland
5b4e957122 MapAdapter: Stable IDs are based on value, not key
This fixes list selection to survive renaming configurations.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-17 08:22:19 -05:00
Samuel Holland
85fc5e7ebf ConfigListFragment: Restore the non-FAB add menu
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-17 06:06:35 -05:00
Samuel Holland
416d3adda7 QuickTileService: Implement and update from VpnService
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-17 05:45:40 -05:00
Samuel Holland
d5d3566e6c BaseConfigActivity: Make use of inner class's this
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-17 05:39:58 -05:00
Samuel Holland
27241d074e VpnService: Use a string to remember the primary config
This allows simplifies the code a bit. Also, a few other minor changes.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-17 04:50:41 -05:00
Samuel Holland
c2189a78b9 ConfigEditFragment: Add extremely basic validation
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-17 03:32:01 -05:00
Samuel Holland
cb48a7be3a Interface: Rework private key handling
This works much better with a data-bound UI -- no confusing erasing of
the text box, and no crashes, either!

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-17 03:30:06 -05:00
Samuel Holland
8bf12f3f55 VpnService: Remove extraneous call to super()
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-17 02:47:53 -05:00
Samuel Holland
44561a9cb6 ObservableArrayMapAdapter: Remove
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-17 02:44:18 -05:00
Samuel Holland
25412e0537 Convert to using the ObservableTreeMap and its adapter
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-17 02:43:15 -05:00
Samuel Holland
97149fff3f ObservableMapAdapter: Based on an observable TreeMap
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-17 02:40:05 -05:00
Samuel Holland
5023c937ad preferences: Control restoring enabled configs
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-16 04:37:11 -05:00
Samuel Holland
b753ae09ca VpnService: Remember and optionally restore enabled configs
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-16 04:36:12 -05:00
Samuel Holland
08992185ec SettingsActivity: Implement primary config setting
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-16 04:34:14 -05:00
Samuel Holland
e95b41e48b ConfigListPreference: ListPreference for configs
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-16 04:29:55 -05:00
Samuel Holland
4ac1a2fafc ConfigList: Denote the primary config with bold text
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-16 04:29:04 -05:00
Samuel Holland
a5e2c1c1b3 BindingAdapters: Create an adapter for textStyle
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-16 04:30:42 -05:00
Samuel Holland
eb43e49a95 VpnService: Remember and maintain the primary config
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-16 04:28:41 -05:00
Samuel Holland
8f0dcd0a32 Config: add an isPrimary property
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-16 04:26:45 -05:00
Samuel Holland
452641a0eb Detail/Edit/ListFragment: Update the layouts
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-16 01:47:18 -05:00
Samuel Holland
645e263424 ConfigActivity: Inline PlaceholderFragment into the layout
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-16 01:43:15 -05:00
Samuel Holland
9e36e0d9c6 ConfigActivity: Make the two-pane layout more readable
Highlight the selected configuration, and add a border between the two
panes.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-16 01:38:46 -05:00
Samuel Holland
76eb65d7d5 Config: Make it Comparable
This will be used for future sorting.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-16 01:06:05 -05:00
Samuel Holland
6d2960b853 ConfigActivity: Adjust when the back arrow is shown
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-16 01:05:13 -05:00
Samuel Holland
73217a098a ConfigListFragment: Implement config selection and removal
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-16 00:55:44 -05:00
Samuel Holland
f1d97a585a Config: Rename function to make databinding happy
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-16 00:57:27 -05:00
Samuel Holland
b60536222d VpnService: Tweaks for ConfigUpdater to fix adding
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-16 00:56:53 -05:00
Samuel Holland
c3203ce90a ConfigDetailFragment: Move function to be in alphabetical order
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-16 00:47:58 -05:00
Samuel Holland
ebb0091ad4 ConfigActivity: Fix restoring layout on resume
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-16 00:46:43 -05:00
Samuel Holland
61d6b89bbe ConfigAddActivity: Add an standalone config-creating activity
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-15 17:36:11 -05:00
Samuel Holland
e9de916d69 BaseConfigActivity: Set initial config when service available
This was accidentally missed earlier when adding the optimization to
omit binding the service when unnecessary.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-15 17:37:06 -05:00
Samuel Holland
7f864badb2 KeyInputFilter: Extract to its own class
It will be reused for entering public keys of peers.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-15 17:33:00 -05:00
Samuel Holland
2103a28f8f ConfigActivity: Show the current config in the title
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-15 17:07:17 -05:00
Samuel Holland
cfcda8bd13 BaseConfigActivity: Move menu handling to ConfigActivity
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-15 16:08:38 -05:00
Samuel Holland
d91770a1b6 ConfigActivity: Show back arrow in single layout action bar
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-14 19:33:19 -05:00
Samuel Holland
6604be94eb ListFragment: Don't assume the ListView is the root
It may share the layout with a FAB, and that requires a parent
ViewGroup.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-14 18:40:46 -05:00
Samuel Holland
e6a6605ff8 ConfigActivity: Fragments are hard; this un-breaks animations
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-14 18:32:14 -05:00
Samuel Holland
ab271e7153 ConfigActivity: Enable animations on fragment transitions
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-14 15:20:57 -05:00
Samuel Holland
83da2aa199 EditFragment: Input filters for config name and private key
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-14 13:53:58 -05:00
Samuel Holland
d5ede015cf ConfigActivity: Avoid crash when started while locked
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-14 10:44:29 -05:00
Samuel Holland
5e55d196be Major renaming and refactoring in activity and service
Apparently "configuration" is the proper term, not "profile".

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-13 07:24:03 -05:00
Samuel Holland
c72d30a1af Profile: Add function to copy config from another profile
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-13 07:23:16 -05:00
Samuel Holland
f84d178e46 ProfileActivity: Remove unnecessary parameterization
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-13 06:22:31 -05:00
Samuel Holland
43500090b2 ProfileService: Rework handling of updates, again
Prefer updating an object instead of replacing it. This preserves the
selection in the UI list. Also make renaming atomic as it should be. Now
the only possibility for data loss is if the old file can be opened but
not written to.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-13 06:16:05 -05:00
Samuel Holland
dacd7457d2 ServiceClientFragment: Connect early if possible
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-10 01:11:00 -05:00
Samuel Holland
5fad89527d ProfileList: Fix state tracking
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-10 01:10:15 -05:00
Samuel Holland
de53a1b50a ProfileEdit: Finish writing code-behind
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-10 01:05:20 -05:00
Samuel Holland
87d3200b29 ProfileActivity: Do menus correctly
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-10 01:04:46 -05:00
Samuel Holland
d6d6f34088 ProfileFragment: Make good use of the cached profile
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-10 00:57:44 -05:00
Samuel Holland
d00480a3a5 Settings: Add empty activity
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-09 07:34:28 -05:00
Samuel Holland
af8e013e33 Hook up editing to the layout and menus
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-09 07:31:12 -05:00
Samuel Holland
c199827b58 ProfileEdit: Add empty activity/fragment
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-09 07:30:25 -05:00
Samuel Holland
671aae7489 ProfileActivity: Do not use onClick for menus
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-09 07:28:04 -05:00
Samuel Holland
7d2d9f0cb3 ProfileActivity: Also remember editing state
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-09 07:25:11 -05:00
Samuel Holland
2c4f605b66 ProfileFragment: Helper class to remember a fragment's profile
Caching the actual profile object is important when the fragment is on
an activity's back stack: when it is shown again, onCreateView will be
called with profile already set and the service already connected. In
this case, there is no later notification from which to bind the
profile, so the existing object needs to be bound there.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-09 07:18:31 -05:00
Samuel Holland
39ed03f758 ProfileList: Add the list fragment in code so it knows the layout
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-09 06:19:37 -05:00
Samuel Holland
52cdf3e7e5 ProfileActivity: Replace fragments instead of hiding
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-09 05:12:00 -05:00
Samuel Holland
2e3daa8913 ProfileActivity: Extract base class for fixing fragments
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-09 03:23:25 -05:00
Samuel Holland
529e320e3f Interface: Correctly handle setting a null or empty key
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-09 02:51:54 -05:00
Samuel Holland
f0f9192aed KeyEncoding: Clean up and reorganize to match style
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-09 02:51:08 -05:00
Samuel Holland
c3afe5be2c Keypair: Convert to java-style array declarations
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-09 02:44:46 -05:00
Jason A. Donenfeld
f6b864d4e7 Constant time base64
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-08 18:22:41 +02:00
Samuel Holland
f8d8e5e23e res: Add icons for quick settings tile
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-08 05:55:27 -05:00
Samuel Holland
99973a4b08 Profile: Add helper to check name validity
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-08 05:54:35 -05:00
Samuel Holland
c59b3e1230 Profile: Make name modifiable
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-08 05:54:12 -05:00
Samuel Holland
0685d4a159 ProfileActivity: Refactor into clean layers of functionality
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-08 05:51:38 -05:00
Samuel Holland
3076fd8c41 ProfileServiceInterface: Update for map-based collection
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-07 20:19:29 -05:00
Samuel Holland
01524c0dbf ProfileService: Use a map to store profile data
This has no visible changes at the moment, but will allow most functions
to pass around strings instead of Profile objects, obviating the need to
implement serialization for them. It also trades some naive linear
searches for the binary search in SimpleArrayMap.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-07 19:55:11 -05:00
Samuel Holland
7d3e796842 ObservableArrayMapAdapter: Copy ObservableListAdapter
Since the conversion to a sequential list (to implement ListAdapter)
depends on the implementation detail that ObservableArrayMap is backed
by an array, we can't use the ObservableMap interface here.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-07 19:46:19 -05:00
Samuel Holland
2df899eae5 ProfileActivity: Add two-pane master-detail layout
This is designed for tablets, but for testing purposes, it is currently
enabled for all devices in landscape orientation.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-07 18:51:47 -05:00
Samuel Holland
2154306fcb PlaceholderFragment: Simple fragment that shows a message
This is used for the detail pane when no profile is selected.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-07 18:48:46 -05:00
Samuel Holland
4c96e55b49 ProfileActivity: Make local variables final
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-07 18:43:52 -05:00
Samuel Holland
00a755f46f ProfileActivityFragment: Fix service connection tracking
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-07 18:42:38 -05:00
Samuel Holland
372477d0e0 ProfileList: Load fragment programmatically
This is necessary to replace it with the profile detail fragment later.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-07 16:55:02 -05:00
Samuel Holland
93e304ba2d ProfileList: Extract service management into a base class
It will be shared with other fragments.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-04 12:39:56 -05:00
Samuel Holland
81ab643d2b ProfileList: Convert to a fragment
This is required for a future two-fragment tablet layout, and simplifies
the code a bit since the profile detail (view/edit) will be implemented
as fragments anyway.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-04 12:24:18 -05:00
Samuel Holland
d0bf3b6b32 ProfileList: remove generated config from UI
It was only there for developing the parser.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-04 00:40:43 -05:00
Samuel Holland
4b401a368f RootShell: Make shell command configurable
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-04 00:37:58 -05:00
Samuel Holland
f0ac53e29b icon: Remove transparency inside non-round dragon
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-04 00:35:02 -05:00
Samuel Holland
6c71b88abd ProfileList: Remove "Add" menu action, to be replaced by a FAB
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-01 02:06:17 -05:00
Samuel Holland
5d5cdf54fa ProfileService: Rework profile updating
This should help discourage editing a Profile without making a copy
first, since the caller has to keep track of the old Profile as well.

ProfileAdder has been updated to prevent adding duplicate profiles. It
checks once in the constructor, so the caller can catch the exception
and pass the error back to the UI. It checks again in the worker thread
to prevent any race from happening if a profile is added twice quickly.
Either the file exists, or it doesn't.

Additionally, this change solves the race condition when the old
profile is removed before it is updated; previously this would lead
to the profile being re-added. Now, ProfileRemover will fail and the
profile will stay removed.

Finally, updating a profile's name should now work correctly. There were
previously multiple bugs with that (the old profile wasn't removed, the
new one could duplicate a name, the new one could overwrite some random
other one, etc.).

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-01 01:38:39 -05:00
Samuel Holland
874db0b95e Interface: Convert to using Keypair class
This allows retrieving the public key and generating keypairs, both of
which will be exposed in the UI.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-01 01:12:59 -05:00
Samuel Holland
19e8087642 Keypair: Create class for generating/storing keys
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-01 01:08:56 -05:00
Samuel Holland
4208d524b1 Curve25519: Import class from noise-java
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-01 01:06:34 -05:00
Samuel Holland
1e0a437c3b RootShell: rename SETUP to SETUP_TEMPLATE
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-04 00:37:29 -05:00
Samuel Holland
e718a7c03c RootShell: Use the application cache dir as TMPDIR
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-31 23:21:59 -05:00
Samuel Holland
544812b2a7 ProfileService: Use wg to enumerate interfaces
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-31 23:11:18 -05:00
Samuel Holland
b324e7b7f1 BootCompletedReceiver: Enforce receiving the correct broadcast
This satisfies an Android security lint.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-31 22:15:50 -05:00
Samuel Holland
84e19d6c72 ProfileList: Add a simple menu
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-29 06:39:37 -05:00
Samuel Holland
411b0716f2 ProfileList: Toggle connection state on click
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-31 21:30:51 -05:00
Samuel Holland
b6653fd7f0 ProfileService: Implement the rest of its interface
As per the FIXMEs, the list of profiles should eventually become a map.
Since it can only be modified on the main thread anyway, the current
code is still safe, and it works, it's just not optimal.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-31 21:22:02 -05:00
Samuel Holland
0ea5ae605c ProfileService: Use deep copy to clone profiles
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-31 21:20:04 -05:00
Samuel Holland
ca708ba382 Profile: Implement deep copying
This is a simple, naive implementation that {,de}serializes the
profile's state, but it does not depend on the internal representation
of Profile or its contained classes.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-31 21:14:42 -05:00
Samuel Holland
c3b42b85cc Copyable: New utility interface for deep-copyable classes
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-31 21:11:33 -05:00
Samuel Holland
465a969a70 ProfileList: Add indicator of profile connection state
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-31 21:29:29 -05:00
Samuel Holland
0451370caf ProfileService: Check for existing interfaces when loading profiles
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-31 21:18:14 -05:00
Samuel Holland
a1e334efa6 Profile: Track connection state
Observability is only enabled for isConnected because it is the only
mutable property.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-31 21:13:01 -05:00
Samuel Holland
8623437185 ProfileService: Expand and document service interface
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-31 19:06:47 -05:00
Samuel Holland
2b56dd5d8f RootShell: Add helper class for running commands as root
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-31 19:00:05 -05:00
Samuel Holland
773190f57d ProfileService: Add a listener to start it on boot
This will allow automatically starting profiles on boot.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-30 02:01:38 -05:00
Samuel Holland
d8a5ec3f19 ProfileService: Only load from files ending with .conf
This condition was previously enforced in the AsyncTask, but was lost in
the move from ProfileListActivity to ProfileService.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-30 02:18:17 -05:00
Samuel Holland
c65ac9fafe ProfileService: Create it and move profile loading
The long-running service is needed for keeping track of which profiles
are enabled, for showing notifications, and for the tile service to use.
Since it has to know which profiles exist anyway, moving the main
ObservableList there avoids some code duplication. It ensures the list
is only loaded once, so it cannot get out of sync. It also makes the
ProfileList activity load faster, because it doesn't have to wait for
file I/O; and it provides a canonical place for storing the Profile
objects so they are accessible everywhere, instead of having to look
them up by name.

This does present some challenges with leaking activities, because all
listeners must be removed from the profiles list (and its contents) when
an activity is stopped.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-30 01:48:57 -05:00
Samuel Holland
5af6703157 binding: Weakly reference adapter in list change callback
This allows the ObservableListAdapter to be garbage collected along with
its activity. On the next list change, the OnListChangedCallback will
detect that the adapter is gone and clean itself up. This avoids needing
to manually remove the list from the adapter, as would otherwise be
required to break the reference cycle adapter→list→listener→adapter.

This will be relevant once the list of profiles outlives the activity.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-30 18:44:57 -05:00
Samuel Holland
7ceafaf2bb ProfileList: Add minimal activity
For now, it simply reads the files in the app's data directory with
file names ending in ".conf" and displays them in a list.

This includes the generic list data binding setup for future use.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-29 06:09:55 -05:00
Samuel Holland
85f1d4f1d3 Profile: Add a blank line before each peer section
This is purely a cosmetic change in the generated config files.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-29 17:40:36 -05:00
Samuel Holland
748d780a47 Profile: Parse config file to a string per attribute
This parser should be able to handle any valid WireGuard or wg-quick
configuration file. It separates the file into a single interface object
and a peer object for each peer. All "[Interface]" sections in the file
are combined into the one object.

For now, later lines in a block with the same key overwrite earlier
lines. This is only relevant for attributes that are lists, such as
Address and AllowedIPs, where additional lines may be expected to append
to the list.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-29 17:30:33 -05:00
Samuel Holland
0494dd1404 Profile: Add minimal implementation
This represents a wg-quick profile as two strings: the file name and
the file contents.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-29 06:08:54 -05:00
Samuel Holland
5a82ecf18a icon: Use the uncropped logo for the non-round icon
The round icon remains the same.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-30 22:47:24 -05:00
Samuel Holland
56cf8816d3 project: Create empty project with WireGuard icon
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-28 23:10:37 -05:00