Compare commits

..

1486 Commits

Author SHA1 Message Date
Jason A. Donenfeld c417bb8d7c version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2025-05-19 18:14:43 +02:00
Jason A. Donenfeld 567fd6ae96 gradle: update to agp 8.10
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2025-05-19 18:11:00 +02:00
Jason A. Donenfeld 2c223fb68c MainActivity: don't reuse id names across layouts
This causes problems on foldables.

Reported-by: Josh Dague <josh3736@gmail.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2025-05-19 17:57:39 +02:00
Jason A. Donenfeld 0ea6cee192 global: add missing xml copyright and opening tag
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2025-05-19 17:40:03 +02:00
Jason A. Donenfeld 0295abd808 global: update copyright notices
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2025-05-19 17:31:02 +02:00
Jason A. Donenfeld 0350b801b6 TunnelCreatorActivity: use proper xml for layout
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2025-05-19 17:26:38 +02:00
Jason A. Donenfeld 4061003ef8 version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2025-05-16 18:49:22 +02:00
Jason A. Donenfeld 3240bd13a8 gradle: update agp to 8.9.3
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2025-05-16 18:49:04 +02:00
Jason A. Donenfeld 720079bdf9 TunnelToggleActivity: suppress errors from prepare() in lockdown mode
Exception java.lang.IllegalStateException: Unavailable in lockdown mode
  at android.os.Parcel.createExceptionOrNull (Parcel.java:3031)
  at android.os.Parcel.createException (Parcel.java:3007)
  at android.os.Parcel.readException (Parcel.java:2990)
  at android.os.Parcel.readException (Parcel.java:2932)
  at android.net.IVpnManager$Stub$Proxy.prepareVpn (IVpnManager.java:1064)
  at android.net.VpnService.prepare (VpnService.java:290)
  at com.wireguard.android.activity.TunnelToggleActivity$onCreate$1.invokeSuspend (TunnelToggleActivity.kt:44)
  at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:8)
  at kotlinx.coroutines.internal.DispatchedContinuationKt.resumeCancellableWith (DispatchedContinuation.kt:155)
  at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable (Cancellable.kt:12)
  at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable$default (Cancellable.kt:12)
  at kotlinx.coroutines.CoroutineStart.invoke (CoroutineStart.java:80)
  at kotlinx.coroutines.AbstractCoroutine.start (AbstractCoroutine.kt:80)
  at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch (BuildersKt__Builders_common.kt:52)
  at kotlinx.coroutines.BuildersKt.launch (Builders.kt:52)
  at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default (BuildersKt__Builders_common.kt:52)
  at kotlinx.coroutines.BuildersKt.launch$default (Builders.kt:52)
  at com.wireguard.android.activity.TunnelToggleActivity.onCreate (TunnelToggleActivity.kt:14)
  at android.app.Activity.performCreate (Activity.java:8591)
  at android.app.Activity.performCreate (Activity.java:8570)
  at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1384)
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:4150)
  at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:4325)
  at android.app.servertransaction.LaunchActivityItem.execute (LaunchActivityItem.java:101)
  at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:135)
  at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:95)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2574)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loopOnce (Looper.java:226)
  at android.os.Looper.loop (Looper.java:313)
  at android.app.ActivityThread.main (ActivityThread.java:8762)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:604)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1067)

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2025-05-16 18:45:19 +02:00
Jason A. Donenfeld aa68b5152e ui: set fitsSystemWindows=true for EdgeToEdge on API 35+
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2025-05-16 18:41:56 +02:00
Jason A. Donenfeld 67db72ac40 TvMainActivity: use OpenDocument instead of GetContent
This should make it possible to open files on Android TV 14.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2025-05-16 18:41:56 +02:00
Jason A. Donenfeld 452a339b37 version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2025-05-15 17:21:52 +02:00
Jason A. Donenfeld 7c743534a5 ui: sync translations
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2025-05-15 17:20:31 +02:00
Jason A. Donenfeld 4df25dd567 build: crowdin now requires auth
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2025-05-15 17:20:08 +02:00
Jason A. Donenfeld 4510fa7482 tools: bump wireguard-go version to latest release
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2025-05-15 16:55:19 +02:00
Jason A. Donenfeld 6aab7cccf9 LogViewerActivity: cast array to Any type instead of using union inference
Type argument for reified type parameter 'T' was inferred to the
intersection of ['Comparable<*>' & 'Serializable']. Reification of an
intersection type results in the common supertype being used. This may
lead to subtle issues and an explicit type argument is encouraged. This
will become an error in a future release.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2025-05-08 04:59:37 +02:00
Jason A. Donenfeld e7d9beaef8 tools: bump go version
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2025-05-08 04:59:37 +02:00
Jason A. Donenfeld bd0967e36e SettingsActivity: manually apply insets for api 35
The forced EdgeToEdge changes don't work well with
PreferenceFragmentCompat, because it's basically abandoned by androidx,
so apply the insets manually ourselves.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2025-05-08 04:59:37 +02:00
Jason A. Donenfeld de2338a470 SettingsActivity: remove unused imports
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2025-05-08 04:59:37 +02:00
Jason A. Donenfeld c9353a89d4 gradle: remove experimental options now on by default
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2025-05-08 04:59:37 +02:00
Jason A. Donenfeld fb115b4079 gradle: use = instead of .set
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2025-05-08 04:59:37 +02:00
Jason A. Donenfeld 0740e86cb2 gradle: bump deps
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2025-05-08 04:59:37 +02:00
Jason A. Donenfeld 9c0bafad17 gradle: update kotlin to 2.1.20
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2025-05-05 16:09:58 +02:00
Jason A. Donenfeld d7242288bb gradle: target API 36
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2025-05-05 16:09:58 +02:00
Jason A. Donenfeld 3e1bf5f9e9 tools: bump wg-go
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2025-05-05 15:44:24 +02:00
Jason A. Donenfeld 55d6ad6c95 gradle: update to agp 8.9.2 and gradle 8.14
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2025-05-05 15:44:24 +02:00
Jason A. Donenfeld 0a8de709b6 version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-10-18 14:26:45 +02:00
Jason A. Donenfeld 83c382b6cc tools: bump go
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-10-18 14:26:41 +02:00
Jason A. Donenfeld 9453b6c0e2 ui: sync with crowdin
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-10-18 14:26:41 +02:00
Jason A. Donenfeld 8390553850 QuickTileService: require SYSTEM_ALERT_WINDOW to start background activity
Due to buggy changes in Android 14, we now need to bother the user about
enabling "draw over other apps" for the quick settings toggle to work
when the app isn't already running.

Link: https://issuetracker.google.com/issues/305035828
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-10-18 14:26:41 +02:00
Jason A. Donenfeld db7f70736f gradle: bump many deps
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-10-13 21:32:16 +02:00
Jason A. Donenfeld d4c8f1dfdd gradle: update to agp 8.2.0-beta06
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-10-13 21:24:42 +02:00
Harsh Shandilya db52515dc6 gradle: upgrade to 8.3
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2023-09-12 12:28:02 +05:30
SlipkHunter 0be12b8d07 ui: only show a snackbar for Android 12 and lower
Signed-off-by: SlipkHunter <abrito025@gmail.com>
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2023-09-12 12:23:46 +05:30
Harsh Shandilya 56be913fa4 gradle: upgrade AGP and Kotlin
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2023-08-04 20:20:46 +05:30
Harsh Shandilya 82bcac55fb gradle: upgrade to 8.2.1
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2023-08-04 20:20:46 +05:30
Jason A. Donenfeld 04e503c9db version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-07-07 05:06:04 +02:00
Jason A. Donenfeld 434534ac59 ui: hide corrupted message if no installer
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-07-07 05:06:04 +02:00
Jason A. Donenfeld 0f77af85d3 ui: sync with crowdin
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-07-07 04:24:14 +02:00
Jason A. Donenfeld 58789d6372 version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-07-06 19:05:55 +02:00
Jason A. Donenfeld adefd16f7e ui: remove unused elvis operators
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-07-06 19:05:52 +02:00
Jason A. Donenfeld e4a49a5356 ui: use api 34's startActivityAndCollapse
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-07-06 19:05:52 +02:00
Jason A. Donenfeld 353679801e tunnel: use record class where possible
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-07-05 18:16:53 +02:00
Jason A. Donenfeld 58ec110360 gradle: remove unused import
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-07-05 17:59:01 +02:00
Jason A. Donenfeld a7ce5ad42a gradle: bump to api 34
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-07-05 16:13:19 +02:00
Jason A. Donenfeld 52c0d1ea29 gradle: update to agp 8.2.0-alpha10
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-07-05 16:00:40 +02:00
Jason A. Donenfeld a5b4b9c428 tunnel: add quotes around calling package
Judging by the previous check, this was clearly intended.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-06-08 15:04:39 +02:00
Jason A. Donenfeld e744ce4569 gradle: update to agp 8.2.0-alpha07
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-06-08 15:03:05 +02:00
Jason A. Donenfeld adfd8e247b tunnel: account for recent magisk using UID in sql
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-06-06 03:08:59 +02:00
Jason A. Donenfeld e9243c403a version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-26 16:23:49 +02:00
Jason A. Donenfeld fbcbfbd311 strings: sync with crowdin
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-26 16:19:52 +02:00
Jason A. Donenfeld dc1d294a82 gradle: bump to core-ktx 1.10.1
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-26 16:19:52 +02:00
Jason A. Donenfeld 2abd426cdc gradle: bump to agp 8.2.0-alpha05
I wanted to stay on 8.1 in hopes of landing on a stable channel, but
Google won't backport the RB fix, so we have to bump to 8.2 alphas.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-26 16:19:52 +02:00
Jason A. Donenfeld c536f5cc7f gradle: bump to agp 8.1.0-beta03
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-26 16:19:52 +02:00
Jason A. Donenfeld 37a892a2da gradle: sort extracted locales rather than generated XML
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-26 16:19:52 +02:00
Jason A. Donenfeld f2d166a6a4 ui: add basic double update guard
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-26 16:19:52 +02:00
Jason A. Donenfeld d883802178 ui: remove debug keys
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-26 16:19:52 +02:00
Jason A. Donenfeld 8d990be204 ui: add missing article to string
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-14 01:18:12 +02:00
Jason A. Donenfeld 5fa2e6164f version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-13 01:12:50 +02:00
Jason A. Donenfeld 9972d9607e gradle: sort lines in localeConfig
This works around https://issuetracker.google.com/issues/281825213

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-13 01:12:15 +02:00
Jason A. Donenfeld 6a72194106 ui: use modal corruption alert instead of snackbar
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-11 13:50:26 +02:00
Jason A. Donenfeld 254e6164d7 ui: use applicationScope helper when possible
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-11 02:57:38 +02:00
Jason A. Donenfeld 675386241b ui: cleanup quick tile and modernize
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-11 02:52:50 +02:00
Jason A. Donenfeld 8671acc1a6 version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-10 20:55:56 +02:00
Jason A. Donenfeld fb08bb6bd4 strings: sync with crowdin
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-10 20:54:29 +02:00
Jason A. Donenfeld 70f8e5ab3a ui: add shortcut for adding quick settings tile
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-10 20:48:11 +02:00
Jason A. Donenfeld e53a8d76f9 gradle: hack around 8.1.0-beta02 api 21 outlining bug
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-10 19:56:08 +02:00
Jason A. Donenfeld e0b4551bca gradle: generate locales for per-app picking
Enable the per-app locale picking menu by adding the right metadata
automatically to the manifest with new AGP automation.

This attempts to follow:
https://developer.android.com/guide/topics/resources/app-languages#use-localeconfig

Using the new AGP feature:
https://developer.android.com/studio/preview/features#automatic-per-app-languages

It appears to work, and it also should squelch the "W AppCompatDelegate:
Checking for metadata for AppLocalesMetadataHolderService : " warnings
on old Android that syphyr pointed out.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-10 19:56:04 +02:00
Jason A. Donenfeld 7b9757bf3b gradle: bump to agp 8.1.0-beta02
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-10 19:56:00 +02:00
Jason A. Donenfeld 4156b83b84 ui: bifurcate only parts of release but nag about wrong context
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-10 19:10:53 +02:00
Jason A. Donenfeld f829b8abe0 gradle: exclude version meta files in release build
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-10 16:54:12 +02:00
Harsh Shandilya 838e0bd6b0 gradle: bump coroutines and MDC
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2023-05-10 18:47:16 +05:30
Jason A. Donenfeld c3f6906309 version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-08 16:10:40 +02:00
Jason A. Donenfeld 5cafd1ebe4 ui: use debug key in debug builds
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-08 14:00:09 +02:00
Jason A. Donenfeld 51991324a9 ui: only register contracts in constructors
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-08 13:31:33 +02:00
Jason A. Donenfeld 33a8a51962 gradle: restore play runtime detection
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-08 13:08:09 +02:00
Jason A. Donenfeld 40eaa54cf0 ui: reformat all code
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-05 13:18:30 +02:00
Jason A. Donenfeld a3bfa6f1ab ui: collect logs from IO thread only
Otherwise the pop() from the producer might causes an OOB read in the
consumer:

Exception java.lang.ArrayIndexOutOfBoundsException:
  at androidx.collection.CircularArray.get (CircularArray.java)
  at com.wireguard.android.activity.LogViewerActivity.rawLogBytes (LogViewerActivity.java)
  at com.wireguard.android.activity.LogViewerActivity.onCreate$lambda$3 (LogViewerActivity.java:133)
  at android.view.View.performClick (View.java:6935)
  at android.view.View$PerformClick.run (View.java:26214)
  at android.os.Handler.handleCallback (Handler.java:790)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loop (Looper.java:164)
  at android.app.ActivityThread.main (ActivityThread.java:7000)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:441)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1408)

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-05 02:56:51 +02:00
Jason A. Donenfeld 7778ff63b5 gradle: use matching fallback instead of build type
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-05 02:43:36 +02:00
Jason A. Donenfeld 79c5eb41c3 version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-04 16:48:23 +02:00
Jason A. Donenfeld 9e30c7d2e9 strings: sync with crowdin
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-03 15:41:41 +02:00
Jason A. Donenfeld d80129ba46 gradle: use += when possible
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-03 15:37:06 +02:00
Jason A. Donenfeld 6907663f07 gradle: don't encourage sticking credentials in files
We've only ever used this via environment variables, so keep it that
way.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-03 14:19:19 +02:00
Jason A. Donenfeld dca96a52b4 gradle: reabstract package name
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-03 14:09:11 +02:00
Jason A. Donenfeld cf4fca8086 gradle: remove runtime detection of play store
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-04 16:45:01 +02:00
Jason A. Donenfeld 318f36a205 README: account for java version updates
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-03 14:23:54 +02:00
Jason A. Donenfeld 87aa73cc64 gradle: use newer desugaring
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-03 14:23:38 +02:00
Jason A. Donenfeld 4e28d57aee gradle: use Java 17
It appears to work, even on API 21.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-03 14:01:05 +02:00
Harsh Shandilya 6d67a3d5f5 gradle: upgrade Kotlin and AGP
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2023-05-03 00:52:52 +05:30
Harsh Shandilya 1b5f4d6dfd gradle: move JVM target up to 11
1.8 is being deprecated across the board

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2023-05-03 00:49:47 +05:30
Harsh Shandilya bed2f2e5d6 gradle: convert build files to Kotlin
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2023-05-03 00:43:18 +05:30
Harsh Shandilya 7d91666860 gradle: update wrapper to 8.1.1
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2023-04-24 11:22:21 +05:30
Jason A. Donenfeld 8800f861ed ui: update cleanups
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-03 14:28:40 +02:00
Jason A. Donenfeld 99336f6552 version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-02 17:59:44 +02:00
Jason A. Donenfeld 0b7b65296b gradle: downgrade wrapper to 8.0.1
This reverts commit 455fcc076becafdf21944aaf2c1f1e9086eb2fd9 because of
f-droid.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-05 12:56:10 +02:00
Jason A. Donenfeld e2f931b4cb ui: use .seconds instead of .toDuration
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-05 12:55:51 +02:00
Jason A. Donenfeld d6ad7d11d0 ui: handle update signatures
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-05-01 16:24:41 +02:00
Jason A. Donenfeld 914917036e version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-27 15:52:23 +02:00
Jason A. Donenfeld 6e9ca435ca gradle: trim experimental list
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-27 13:51:25 +02:00
Jason A. Donenfeld 0797e99559 proguard: cleanup unused parts
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-27 13:12:02 +02:00
Jason A. Donenfeld 0ba064ff48 build: bump activity-ktx and fragment-ktx
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-25 14:53:41 +02:00
Jason A. Donenfeld b4fe9efadb strings: sync with crowdin
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-13 18:49:36 +02:00
Jason A. Donenfeld b1b08ce716 ui: display latest handshake time
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-24 18:07:03 +02:00
Jason A. Donenfeld 20480992c4 tunnel: export latest handshake stat
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-24 18:06:57 +02:00
Harsh Shandilya 9df90b259a gradle: update wrapper to 8.1.1
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2023-04-24 11:22:21 +05:30
Jason A. Donenfeld b94a412c09 tools: build elf-cleaner using system compiler
Rather than using the NDK compiler for the host arch and hoping it picks
up on system library locations, just use `cc` and rely on the
traditional symlink to resolve that to the default host compiler.

This should address build errors seen on macOS.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-21 15:43:25 +02:00
Jason A. Donenfeld 0b0a553123 ui: remove unused extra_margin constant
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-13 19:36:20 +02:00
Jason A. Donenfeld 6d4d2f4ebf tools: ndk-compat: NDK now is minimum API 19
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-13 19:24:50 +02:00
Jason A. Donenfeld e55358f685 build: bump AGP to 8.0.0
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-27 14:21:47 +02:00
Jason A. Donenfeld c2fdd0ca93 ui: layout: don't stretch text fields, so that alignment is correct
This makes things look uniform on RTL.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-13 17:47:36 +02:00
Jason A. Donenfeld 19044b0f53 ui: LogViewerActivity: cleanup ret val
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-13 16:06:54 +02:00
Jason A. Donenfeld d4e77e6d57 version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-12 15:48:04 +02:00
Jason A. Donenfeld 6ba3e4f001 tools: do not put vcs info into go binary
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-12 15:48:01 +02:00
Jason A. Donenfeld 8152191277 ui: further reduce log viewer memory usage
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-12 13:48:55 +02:00
Jason A. Donenfeld 8c6c909e98 tools: bump go
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-11 19:52:30 +02:00
Jason A. Donenfeld fdda87fd31 tunnel: defer enabling strict mode until later
Startup code can be synchronous.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-11 19:20:26 +02:00
Jason A. Donenfeld 3907f6a4c1 tunnel: do not keep service running when bringing tunnel down
Doing so causes the process to restart when the activity is cleared,
even when no tunnel is running. I fear this might also lead to the
current flurry of DeadSystemExceptions.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-11 19:17:55 +02:00
Jason A. Donenfeld 652971d746 tools: clean compile options a bit
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-11 16:23:37 +02:00
Jason A. Donenfeld 1bf8d7e4c4 build: shrink resources
Saves 300k.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-10 18:19:52 +02:00
Jason A. Donenfeld 3c834ac8e3 ui: always show visible localized error messages
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-07 15:22:00 +02:00
Jason A. Donenfeld 8669ae78e1 ui: set app list button text on main thread
Hopefully will fix, "Only the original thread that creted a view
hierarchy can touch its views."

Reported-by: Damir <2k1dmg@gmail.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-07 15:18:33 +02:00
Jason A. Donenfeld 53f8c8dbc4 build: remove bespoke signing config properties
Keys should be in HSMs anyway, and a setup like this does not easily
allow for that.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-06 17:16:29 +02:00
Jason A. Donenfeld 1328660b0b build: bump deps
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-05 22:19:37 +02:00
Jason A. Donenfeld 997edf4e4c version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-05 17:09:41 +02:00
Jason A. Donenfeld beb40ad09c ui: allow vetoing tunnel selection changes
These changes can happen at the wrong time, so we need to be able to
walk them back. Fixes:

Exception java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
  at androidx.fragment.app.FragmentManager.checkStateLoss (FragmentManager.java:1610)
  at androidx.fragment.app.FragmentManager.enqueueAction (FragmentManager.java:1650)
  at androidx.fragment.app.BackStackRecord.commitInternal (BackStackRecord.java:341)
  at androidx.fragment.app.BackStackRecord.commit (BackStackRecord.java:306)
  at androidx.fragment.app.FragmentManagerKt.commit$default (FragmentManager.kt:35)
  at com.wireguard.android.activity.MainActivity.onSelectedTunnelChanged (MainActivity.kt:113)
  at com.wireguard.android.activity.BaseActivity.setSelectedTunnel (BaseActivity.kt:25)
  at com.wireguard.android.activity.BaseActivity$onCreate$1.invokeSuspend (BaseActivity.kt:44)
  at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:33)
  at kotlinx.coroutines.internal.DispatchedContinuation.resumeUndispatchedWith (DispatchedContinuation.java:256)
  at kotlinx.coroutines.DispatchedTaskKt.resume (DispatchedTask.kt:177)
  at kotlinx.coroutines.CancellableContinuationImpl.parentCancelled$kotlinx_coroutines_core (CancellableContinuationImpl.kt:190)
  at kotlinx.coroutines.DispatchedTaskKt.resumeUnconfined (DispatchedTask.kt:190)
  at kotlinx.coroutines.DispatchedTaskKt.dispatch (DispatchedTask.kt:161)
  at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume (CancellableContinuationImpl.kt:397)
  at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl (CancellableContinuationImpl.kt:431)
  at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$default (CancellableContinuationImpl.kt:420)
  at kotlinx.coroutines.CancellableContinuationImpl.resumeWith (CancellableContinuationImpl.kt:328)
  at kotlinx.coroutines.ResumeAwaitOnCompletion.invoke (JobSupport.kt:1413)
  at kotlinx.coroutines.JobSupport.notifyHandlers (JobSupport.kt:368)
  at kotlinx.coroutines.JobSupport.notifyCompletion (JobSupport.kt:362)
  at kotlinx.coroutines.JobSupport.completeStateFinalization (JobSupport.kt:323)
  at kotlinx.coroutines.JobSupport.finalizeFinishingState (JobSupport.kt:240)
  at kotlinx.coroutines.JobSupport.tryMakeCompletingSlowPath (JobSupport.kt:906)
  at kotlinx.coroutines.JobSupport.tryMakeCompleting (JobSupport.kt:863)
  at kotlinx.coroutines.JobSupport.makeCompleting$kotlinx_coroutines_core (JobSupport.kt:806)
  at kotlinx.coroutines.CompletableDeferredImpl.complete (CompletableDeferredImpl.java:92)
  at com.wireguard.android.model.TunnelManager$onTunnelsLoaded$1.invokeSuspend (TunnelManager.kt:120)
  at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:33)
  at kotlinx.coroutines.DispatchedTask.run (DispatchedTask.kt:106)
  at android.os.Handler.handleCallback (Handler.java:938)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loop (Looper.java:237)
  at android.app.ActivityThread.main (ActivityThread.java:8163)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:656)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:967)

Exception java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
  at androidx.fragment.app.FragmentManager.checkStateLoss (FragmentManager.java:1610)
  at androidx.fragment.app.FragmentManager.enqueueAction (FragmentManager.java:1650)
  at androidx.fragment.app.BackStackRecord.commitInternal (BackStackRecord.java:341)
  at androidx.fragment.app.BackStackRecord.commit (BackStackRecord.java:306)
  at androidx.fragment.app.FragmentManagerKt.commit$default (FragmentManager.kt:35)
  at com.wireguard.android.activity.MainActivity.onSelectedTunnelChanged (MainActivity.kt:113)
  at com.wireguard.android.activity.BaseActivity.setSelectedTunnel (BaseActivity.kt:25)
  at com.wireguard.android.activity.BaseActivity$onCreate$1.invokeSuspend (BaseActivity.kt:44)
  at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:33)
  at kotlinx.coroutines.internal.DispatchedContinuation.resumeUndispatchedWith (DispatchedContinuation.java:256)
  at kotlinx.coroutines.DispatchedTaskKt.resume (DispatchedTask.kt:177)
  at kotlinx.coroutines.CancellableContinuationImpl.parentCancelled$kotlinx_coroutines_core (CancellableContinuationImpl.kt:190)
  at kotlinx.coroutines.DispatchedTaskKt.resumeUnconfined (DispatchedTask.kt:190)
  at kotlinx.coroutines.DispatchedTaskKt.dispatch (DispatchedTask.kt:161)
  at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume (CancellableContinuationImpl.kt:397)
  at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl (CancellableContinuationImpl.kt:431)
  at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$default (CancellableContinuationImpl.kt:420)
  at kotlinx.coroutines.CancellableContinuationImpl.resumeWith (CancellableContinuationImpl.kt:328)
  at kotlinx.coroutines.ResumeAwaitOnCompletion.invoke (JobSupport.kt:1413)
  at kotlinx.coroutines.JobSupport.notifyHandlers (JobSupport.kt:368)
  at kotlinx.coroutines.JobSupport.notifyCompletion (JobSupport.kt:362)
  at kotlinx.coroutines.JobSupport.completeStateFinalization (JobSupport.kt:323)
  at kotlinx.coroutines.JobSupport.finalizeFinishingState (JobSupport.kt:240)
  at kotlinx.coroutines.JobSupport.tryMakeCompletingSlowPath (JobSupport.kt:906)
  at kotlinx.coroutines.JobSupport.tryMakeCompleting (JobSupport.kt:863)
  at kotlinx.coroutines.JobSupport.makeCompleting$kotlinx_coroutines_core (JobSupport.kt:806)
  at kotlinx.coroutines.CompletableDeferredImpl.complete (CompletableDeferredImpl.java:92)
  at com.wireguard.android.model.TunnelManager$onTunnelsLoaded$1.invokeSuspend (TunnelManager.kt:120)
  at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:33)
  at kotlinx.coroutines.DispatchedTask.run (DispatchedTask.kt:106)
  at android.os.Handler.handleCallback (Handler.java:938)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loopOnce (Looper.java:210)
  at android.os.Looper.loop (Looper.java:299)
  at android.app.ActivityThread.main (ActivityThread.java:8302)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:556)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1037)

Exception java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
  at androidx.fragment.app.FragmentManager.checkStateLoss (FragmentManager.java:1610)
  at androidx.fragment.app.FragmentManager.ensureExecReady (FragmentManager.java:1711)
  at androidx.fragment.app.FragmentManager.execPendingActions (FragmentManager.java:1754)
  at androidx.fragment.app.FragmentManager.popBackStackImmediate (FragmentManager.java:854)
  at androidx.fragment.app.FragmentManager.popBackStackImmediate (FragmentManager.java:778)
  at com.wireguard.android.activity.MainActivity.onSelectedTunnelChanged (MainActivity.kt:110)
  at com.wireguard.android.activity.BaseActivity.setSelectedTunnel (BaseActivity.kt:25)
  at com.wireguard.android.activity.BaseActivity$onCreate$1.invokeSuspend (BaseActivity.kt:44)
  at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:33)
  at kotlinx.coroutines.DispatchedTask.run (DispatchedTask.kt:106)
  at kotlinx.coroutines.EventLoop.processUnconfinedEvent (EventLoop.common.kt:69)
  at kotlinx.coroutines.DispatchedTaskKt.runUnconfinedEventLoop (DispatchedTask.kt:204)
  at kotlinx.coroutines.internal.DispatchedContinuationKt.resumeCancellableWith (DispatchedContinuation.kt:282)
  at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable (Cancellable.kt:30)
  at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable$default (Cancellable.kt:25)
  at kotlinx.coroutines.CoroutineStart.invoke (CoroutineStart.java:110)
  at kotlinx.coroutines.AbstractCoroutine.start (AbstractCoroutine.kt:126)
  at kotlinx.coroutines.BuildersKt.launch$default (Builders.kt)
  at com.wireguard.android.model.TunnelManager.onTunnelsLoaded (TunnelManager.java:114)
  at com.wireguard.android.model.TunnelManager.access$onTunnelsLoaded (TunnelManager.java:40)
  at com.wireguard.android.model.TunnelManager$onCreate$1.invokeSuspend (TunnelManager.kt:104)
  at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:33)
  at kotlinx.coroutines.DispatchedTask.run (DispatchedTask.kt:106)
  at android.os.Handler.handleCallback (Handler.java:942)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loopOnce (Looper.java:226)
  at android.os.Looper.loop (Looper.java:313)
  at android.app.ActivityThread.main (ActivityThread.java:8757)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:571)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1067)

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-05 17:08:47 +02:00
Jason A. Donenfeld 4bac284083 ui: don't use primary color on status bar < api 23
The primary color changes in night theme, and since there's no proper
mode for the status icons on those APIs, it looks bad.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-05 16:20:10 +02:00
Jason A. Donenfeld eae9216fe4 ui: no need to manually recreate activities after night change
Since version 1.1.0, setDefaultNightMode now takes care of that. Also,
set the initial mode in a blocking fashion to prevent flashing white.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-05 16:03:54 +02:00
Jason A. Donenfeld dc1860c74d ui: distinguish play store installs at runtime for reproducible builds
This change lets us use the same build for F-Droid, Play Store, self
builds, and elsewhere, which makes everything more easily publicly
verifiable, since the build system is reproducible. That means that all
APKs will have the same code and be completely interchangeable, no
matter where they come from.

It does this by removing the build-time branch for special Play Store
builds, and replacing it with a simple runtime check using the
PackageManager APIs that return the name of the installer. If the app is
installed by "com.android.vending", then it's a Play Store install.

It's possible to test this with:

    $ pm install -i com.android.vending path/to/package.apk

And it appears to work well.

One potential concern is that it's unclear whether the Play Store
reviewers install the app using utilities that set com.android.vending
like this. If not, that might be a problem. However, it looks like
various banking apps also use the installer package name check in the
same way, and refuse to start if it's not right. That suggests that it
would be impossible for Play Store reviewers to even review those
banking apps if they did not set com.android.vending properly.

Out of an abundance of caution, though, and in order to avoid a Play
Store suspension that's harder to appeal, I sent a support request
today (which just managed to fit exactly in the 1000 character limit):

    Hi,

    My app pays special attention to Google Play Store guidelines. For that
    reason, there is some code in the app that looks like this:

        if (BuildConfig.IS_GOOGLE_PLAY)
            ...
        else
            ...

    This means that I compile two versions of my app, one for Google Play,
    and another for other app stores. This has worked well for many years
    and it satisfies Google's policy requirements.

    However, compiling two versions of my app is a bit of a pain. Instead, I
    would like to do this check at runtime, with code like this:

        if (pm.getInstallSourceInfo(package).installingPackageName == "com.android.vending")
            ...
        else
            ...

    I have tested that this code works well, and I've installed my app with:

        $ pm install -i com.android.vending ui-release.apk

    This works and successfully satisfies the policy requirements.

    My question is how this works during the review process. Are reviewed
    apps installed with the necessary -i com.android.vending switch to make
    this work?

    Thanks.

They responded fairly quickly:

    Hi Jason,

    Thanks for contacting the Google Play team.

    Unfortunately I'm not able to comment on your planned implementation. If
    you think your app is in compliance, please submit your app for review.
    You may want to review the Developer Program Policies for additional
    policy guidance.

    We recommend reviewing the details listed in this blog post and update
    your app accordingly to comply with the changes.

    Thanks for your understanding and continued support.

    Regards,
    Mia
    Google Play Developer Support

So I'll interpret that as a, "if you think it's okay, submit it and see,
and then we'll let you know." So here we go. Hopefully if it is
rejected, the update will only be blocked, and I'll just revert this
commit and resubmit.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-05 13:54:23 +02:00
Jason A. Donenfeld 6209d3ee3d tools: clean unwanted ELF flags from binaries
Fixes warnings on old Android, such as:

linker  : /data/data/com.wireguard.android/code_cache/bin/wg-quick: unsupported flags DT_FLAGS_1=0x8000001
linker  : /data/data/com.wireguard.android/code_cache/bin/wg: unsupported flags DT_FLAGS_1=0x8000001

Reported-by: L.W.Reek <syphyr@gmail.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-05 13:50:57 +02:00
Jason A. Donenfeld 33aded09c6 tools: deduplicate cmake arguments
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-05 13:50:57 +02:00
Jason A. Donenfeld f360034f29 tools: remove cmake dependency hack
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-05 12:23:41 +02:00
L.W.Reek 01e72064d4 tools: add missing CLOCK_BOOTTIME case to mips64x
Signed-off-by: L.W.Reek <syphyr@gmail.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-05 02:49:26 +02:00
Jason A. Donenfeld 91a75b681d ui: always use MaterialAlertDialogBuilder
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-04 21:41:49 +02:00
Jason A. Donenfeld 0efdf0cdd7 strings: sync with crowdin
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-04 20:54:29 +02:00
Jason A. Donenfeld 75efd13556 ui: don't create fake theme color attr
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-04 20:53:42 +02:00
Jason A. Donenfeld cd812b03cd ui: force dark theme in TV mode
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-04 20:53:42 +02:00
Jason A. Donenfeld 794a2a1925 ui: use filled icon buttons in TV mode
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-04 20:53:42 +02:00
Jason A. Donenfeld 75899594c3 ui: use real M3 themeing on TV
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-04 20:53:42 +02:00
Jason A. Donenfeld 4944762d7c ui: redirect to play store if no file manager on tv
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-04 20:53:42 +02:00
Jason A. Donenfeld d6431db248 ui: detect tv framework stubs when getting content
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-04 20:53:42 +02:00
Jason A. Donenfeld b8f649d1cb ui: use ErrorMessages consistently
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-04 20:53:42 +02:00
Jason A. Donenfeld 9fa8ca8c77 ui: do not crash if tunnel preparation fails
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-04 15:31:52 +02:00
Jason A. Donenfeld 59da677c23 ui: do not OOM when leaving log window open for a while
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-04 15:31:52 +02:00
Jason A. Donenfeld 18a06b0a51 ui: show bottom sheet sync to prevent double add
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-04 15:31:52 +02:00
Jason A. Donenfeld 5e844bed5e ui: do not return to detail page when restoring state
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-04 15:31:52 +02:00
Jason A. Donenfeld 46bf98d7f6 ui: never access CREATOR directly
All of the parcelers have their own type prefix. So we have to actually
use the legit methods. This is a bit annoying, as there's no fully
compatible way across all API versions, so we have to branch.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-04 15:31:52 +02:00
Jason A. Donenfeld 3e9ddd8720 ui: never throw on link clicks
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-04 15:31:52 +02:00
Jason A. Donenfeld 9e33d9e56b version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-04 15:31:52 +02:00
Jason A. Donenfeld 9fae327315 tools: pass -Wl,--build-id=none and -buildid= to toolchain
Unfortunately, we need to fix this up in both the Makefile and in CMake,
because add_link_options doesn't immediately reflect on the CMake
variables in scope.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-04 15:14:28 +02:00
Jason A. Donenfeld a6f5eb0dd2 build: exclude extra kotlin cruft from release build
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-04-04 15:14:28 +02:00
Jason A. Donenfeld c3c4cd05b1 ui: don't play with status and navigation colors on old APIs
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-30 16:05:41 +02:00
Jason A. Donenfeld 58c19385a3 ui: do not allow double clicking fab to show menu twice
Exception java.lang.IllegalStateException:
  at androidx.fragment.app.FragmentStore.addFragment (FragmentStore.java:92)
  at androidx.fragment.app.FragmentManager.addFragment (FragmentManager.java:1481)
  at androidx.fragment.app.BackStackRecord.executeOps (BackStackRecord.java:387)
  at androidx.fragment.app.FragmentManager.executeOps (FragmentManager.java:1965)
  at androidx.fragment.app.FragmentManager.executeOpsTogether (FragmentManager.java:1873)
  at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute (FragmentManager.java:1823)
  at androidx.fragment.app.FragmentManager.execPendingActions (FragmentManager.java:1760)
  at androidx.fragment.app.FragmentManager$5.run (FragmentManager.java:547)
  at android.os.Handler.handleCallback (Handler.java:938)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loop (Looper.java:268)
  at android.app.ActivityThread.main (ActivityThread.java:8101)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:627)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:997)

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-30 15:15:39 +02:00
Jason A. Donenfeld 354e1c0ed9 ui: remove unneeded @JvmStatic annotations
These are only needed on methods called from databindings, since those
compile to java.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-30 15:07:45 +02:00
Jason A. Donenfeld 02b9677a9c ui: add list selection highlight color for tablet
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-30 14:53:28 +02:00
Jason A. Donenfeld 82d26e61da ui: the button is not always blue with Material You
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-30 14:23:10 +02:00
Jason A. Donenfeld a113770868 ui: use app resources instead of ctx for strings in callback
Exception java.lang.IllegalStateException:
  at androidx.fragment.app.Fragment.requireContext (Fragment.java:967)
  at com.wireguard.android.fragment.TunnelListFragment$tunnelFileImportResultLauncher$1$1.invokeSuspend (TunnelListFragment.kt:64)
  at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:33)
  at kotlinx.coroutines.DispatchedTask.run (DispatchedTask.kt:104)
  at android.os.Handler.handleCallback (Handler.java:761)
  at android.os.Handler.dispatchMessage (Handler.java:98)
  at android.os.Looper.loop (Looper.java:156)
  at android.app.ActivityThread.main (ActivityThread.java:6617)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:942)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:832)

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-30 13:54:06 +02:00
Jason A. Donenfeld b734f44200 ui: use M3 theme for TV to prevent crash
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-30 13:40:05 +02:00
Jason A. Donenfeld ee16d1329b version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-28 18:32:34 +02:00
Jason A. Donenfeld 900654e6b1 tools: use NDK's make binary rather than system's
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-28 18:31:38 +02:00
Jason A. Donenfeld a0cba19645 strings: sync crowdin
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-28 17:53:43 +02:00
Jason A. Donenfeld d7ccbd92e5 ui: add log items in buffered batches
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-28 17:47:36 +02:00
Jason A. Donenfeld 2da80e8dee ui: color verbose logs the same as debug logs
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-28 16:02:47 +02:00
Jason A. Donenfeld 450ef8ce1c ui: don't call getColor on already resolved attribute
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-28 16:02:47 +02:00
Jason A. Donenfeld 58e7b7a069 ui: bring back dark log viewer colors
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-28 16:02:47 +02:00
Harsh Shandilya d354831c6a ui: fix inconsistent style naming
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2023-03-28 17:42:35 +05:30
Harsh Shandilya fcb7caed23 gradle: opt into new publishing APIs
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2023-03-28 17:42:07 +05:30
Harsh Shandilya c7d1c4baba ui: adjust log viewer text sizes
10sp is below the minimum 11sp recommended for readability

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2023-03-28 00:53:18 +05:30
Harsh Shandilya 76423ce868 ui: use M3 styles everywhere
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2023-03-28 00:51:47 +05:30
Jason A. Donenfeld b37006ce2f ui: add possibility for themed icon
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-27 18:05:39 +02:00
Jason A. Donenfeld b072130e37 ui: add list selection backgrounds
Harsh - feel free to replace this commit with something better. I'm sure
it's the most terrible way to do it.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-27 18:00:00 +02:00
Jason A. Donenfeld 54dfa7bdd7 ui: cancel actionmode when pressing back button
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-27 17:59:00 +02:00
Jason A. Donenfeld e5a75307c2 ui: simplify actionmode cast
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-27 17:47:09 +02:00
Harsh Shandilya 4fcb8c4792 ui: introduce a fresh set of Material3 themes and migrate to them
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2023-03-27 16:10:24 +02:00
Harsh Shandilya fb05b358c0 ui: use AndroidX BundleCompat for extracting parcelable
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2023-03-27 16:11:30 +05:30
Jason A. Donenfeld f13624c58f ui: switch from SwitchMaterial to MaterialSwitch
This required some weird changes to prevent clipping on the top, because
apparently the new switch is a bit fatter.

I think this actually looks a bit uglier than before, but it seems like
that's what Material design wants. Maybe we can improve it?

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-25 23:58:06 +01:00
Jason A. Donenfeld 497a60cc90 ui: bring back donation button
For Google Play Store builds, we'll display an alert box. This was
inspired by the discussion around StreetComplete; hopefully we'll have a
similar okay outcome.

Link: https://github.com/streetcomplete/streetcomplete/issues/3768
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-24 14:16:08 +01:00
Jason A. Donenfeld 8139e60094 strings: update from crowdin
This is after doing a rebuild on the crowdin side.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-24 14:12:21 +01:00
Harsh Shandilya 9dab67f3f1 ui: fix inconsistent toolbar color
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2023-03-24 14:12:21 +01:00
Harsh Shandilya e342c9a28f ui: use Material switch component
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2023-03-24 14:12:21 +01:00
Jason A. Donenfeld cf943b7119 ui: migrate to OnBackPressedDispatcher
This is compatible with Android 13's prediction-based back gesture
animation.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-24 14:12:21 +01:00
Harsh Shandilya b7295cd56f build: raise target SDK to 33
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2023-03-24 14:12:21 +01:00
Jason A. Donenfeld 763d9a9f17 ui: set selected tunnel after creating fragments
I'm not sure why that comment (Samuel's) was there saying it was
necessary. Given it's been async for a long while, this wasn't
guaranteed anyway. So let's get rid of it and see what happens. Screen
rotation seems fine thus far.

Cc: Samuel Holland <samuel@sholland.org>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-24 14:12:21 +01:00
Jason A. Donenfeld f3107e349c ui: switch from using launchWhenCreated to using repeatOnLifecycle
Apparently the former is deprecated.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-24 14:12:21 +01:00
Jason A. Donenfeld caf2cded6e ui: simplify IME displaying in ConfigNamingDialogFragment
Also cleanup some event listener flow.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-24 14:12:21 +01:00
Harsh Shandilya b44380c81a ui: migrate to MenuProvider
AndroidX Activity 1.4.0 introduced the new lifecycle-dependent MenuProvider
APIs that supersede existing onCreateOptionsMenu-style menus.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2023-03-22 21:35:34 +05:30
Harsh Shandilya 35c8c10b7e ui: address Parcelable API deprecations
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2023-03-22 21:35:34 +05:30
Harsh Shandilya 91227e445a ui: address PackageManager API deprecations
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2023-03-22 21:35:34 +05:30
Harsh Shandilya 94e6d99dc7 gradle: upgrade AndroidX libraries
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2023-03-22 21:35:34 +05:30
Harsh Shandilya 052ff060b1 gradle: use idiomatic task handling
- The hand-rolled clean task is not required

- Tasks should use configureEach to prevent eager evaluation

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2023-03-22 21:35:34 +05:30
Harsh Shandilya e843fccbc6 gradle: bump wrapper version
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2023-03-22 21:35:34 +05:30
Jason A. Donenfeld 3ab1f94514 tools: compile with latest NDK
The -mthumb -> -marm hack is unfortunate.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-22 15:02:54 +01:00
Jason A. Donenfeld 4aa4843b74 tools: use __ANDROID_MIN_SDK_VERSION__ instead of __ANDROID_API__
The latter is deprecated.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-22 15:02:54 +01:00
Jason A. Donenfeld 4d00c334b1 ui: set button text after loading app list in AppListDialogFragment
Otherwise, for lots of apps, the dialog shows before they're enumerated,
and the button text never gets set.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-22 15:02:54 +01:00
Jason A. Donenfeld 62986b5cad version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-21 15:53:39 +01:00
L.W.Reek 296295ab8a gradle: use same NDK for tunnel and UI
Fixes: 4f261560 ("gradle: force the use of an older NDK version")
Signed-off-by: L.W.Reek <syphyr@gmail.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-21 15:53:39 +01:00
L.W.Reek d1237e2718 build: Google Play requires target API level 31 or higher
Fix build failure from lint check

Signed-off-by: L.W.Reek <syphyr@gmail.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-21 15:53:39 +01:00
Jason A. Donenfeld a26b7c594a strings: sync with crowdin
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-21 15:47:26 +01:00
Jason A. Donenfeld 853e86e6d0 global: bump copyright date
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-21 15:41:11 +01:00
Jason A. Donenfeld a386e3a3d2 build: update to gradle 7.4.2 and restructure lint block
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-21 15:35:00 +01:00
Jason A. Donenfeld 560d9cf967 tools: bump deps
Notably, this isn't bumping to the latest wireguard-go master, which is
still in flux.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-21 15:35:00 +01:00
SlipkHunter 713947e432 gradle: adjust for and raise compileSdk to 33
Signed-off-by: SlipkHunter <abrito025@gmail.com>
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2023-01-20 19:54:23 +05:30
Harsh Shandilya f8690ca215 gradle: migrate to namespace attribute
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2023-01-20 19:37:41 +05:30
SlipkHunter 4f26156030 gradle: force the use of an older NDK version
NDK 25.x removed the bundled ld.gold/ld.bfd linkers, replacing
them with the ld.ldd linker from LLVM. This causes the toolchains
to pick up the host OS' `ld.gold` instead, which does not
know how to link ARM(64) code and fails the build.

Fixes: f269fb175d ("gradle: update AndroidX and Kotlin")
Signed-off-by: SlipkHunter <abrito025@gmail.com>
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2023-01-20 19:37:41 +05:30
Harsh Shandilya b353ed8ae9 gradle: update AGP and Kotlin
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2023-01-20 19:37:41 +05:30
Harsh Shandilya f269fb175d gradle: update AndroidX and Kotlin
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2022-12-01 00:15:39 +05:30
Harsh Shandilya 98fe4438d5 gradle: bump wrapper version
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2022-12-01 00:15:39 +05:30
Hwanseung Lee 0459d6d9f4 ui: un-export VpnService
There is no reason to expose this service to external apps.[1]

[1] https://developer.android.com/guide/topics/manifest/activity-element#exported

Signed-off-by: Hwanseung Lee <hwanseung@chromium.org>
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2022-12-01 00:15:39 +05:30
Harsh Shandilya 4ff564521f gradle: upgrade plugins and runtime dependencies
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2022-08-04 02:12:38 +05:30
Harsh Shandilya 9f139134c2 gradle: bump wrapper version
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2022-08-04 02:12:37 +05:30
SlipkHunter 284ad03ebf ui: add barrier to fix detail fragment overlap
When listen port and MTU are hidden, we need a barrier here.

Signed-off-by: SlipkHunter <abrito025@gmail.com>
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2022-07-07 15:35:10 +02:00
Harsh Shandilya c3693b3e66 gradle: remove crowdin kludge
This never ended up being used over the shell script

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2022-06-15 12:51:37 +05:30
Harsh Shandilya 960bc99f5e gradle: update AndroidX and Kotlin
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2022-06-15 12:51:37 +05:30
Lucas Lee Jing Yi 8d33b648cc gradle: remove duplicate useAndroidX entry
Signed-off-by: Lucas Lee Jing Yi <lucasleeeeeeeee@gmail.com>
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2022-06-15 12:51:31 +05:30
Harsh Shandilya 38cb184cf8 ui: reorder constraints to fix detail fragment overlap
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2022-05-26 06:50:00 +05:30
Harsh Shandilya 5d14caf3b2 ui: move default style to Material3 with Dynamic Colors
The TV theme has been kept as-is since Material You guidance around this
is a bit scarce at the moment.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2022-05-26 06:49:22 +05:30
Harsh Shandilya 81c571f0c7 ui: normalise icon tints and remove unused drawable
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2022-05-26 06:01:03 +05:30
Harsh Shandilya 50b21e95c3 gradle: bump ConstraintLayout and MDC
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2022-05-26 06:01:03 +05:30
Harsh Shandilya 059bf88141 gradle: bump AGP and Kotlin
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2022-05-26 06:01:02 +05:30
Harsh Shandilya b3112ab0bd gradle: bump to 7.4.2
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2022-05-26 06:01:02 +05:30
Harsh Shandilya 1bb8a10633 ui: remove unnecessary boolean check
This check was added in 3c31c340d8 when the kernel module loader was
introduced into the app lifecycle, to avoid attempting to start a root shell
twice. When the module loader was removed in a03ad51622, this flag
was accidentally left in when it should have been deleted.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2022-05-26 06:01:02 +05:30
Harsh Shandilya f3230fc8f9 idea: squelch XML codestyle warning
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2022-05-26 06:01:02 +05:30
Jason A. Donenfeld c762bc3120 version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2022-05-16 19:17:40 +02:00
Jason A. Donenfeld aeb8903ba2 tools: bump deps
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2022-05-16 19:15:07 +02:00
Shahzain Ali 2f244771a2 ui: move target SDK to 31
Signed-off-by: Shahzain Ali <shahzainali93@gmail.com>
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2022-04-26 01:27:41 +05:30
Harsh Shandilya 5ffb1d0c36 gradle: bump AGP and Kotlin
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2022-04-08 03:08:22 +05:30
Jason A. Donenfeld 62910caae1 tools: bump wireguard-go and go 1.18
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2022-03-20 22:31:57 -06:00
Vlad Loktionov 866fd35df5 ui: word wrap settings headers
Apparently some translations make this wrap, which is bad.

Signed-off-by: Vlad Loktionov <yobabay23@gmail.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2022-03-20 22:28:14 -06:00
Rin Patch 32a2ebb66f ui: exclude TunnelToggleActivity from recents
Fixes annoying behavior in quick settings widget, when you enable
the tunnel, try to switch to last used app, but instead it switches to
the toggle activity and turns the tunnel off.

Signed-off-by: Rin Patch <rin@patch.cx>
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2022-03-20 22:28:07 -06:00
Harsh Shandilya 70d9a87d0d ui: make validity check from QR code image scanner static
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2022-03-06 10:48:15 -07:00
Nikita Pustovoi 0bd39309c8 ui: allow importing tunnel from an QR image stored on the device
Add a new feature to import a tunnel from a saved QR image, this feature
integrates into 'import from file' flow, however adds a condition, if
file is an image, attempt to parse it as QR image file.

My use case for this feature, is to allow easier sharing of tunnels to
family.  Scanning QR code is ok when you have an external display to
show it, but if you sent QR code to someone, there is no way to import
it in the app.  If you share a config file, that becomes way harder for
a non-technical person to import as now they need to find a file with
that name in the file picker etc etc, Where the images are very visible
in the file picker, and user can easily recognize it for import.

Testing:
- Click "+" blue button, try to import a valid `.conf` file - the
  'original' file flow should not be affected
- Click "+" blue button, try to import a valid QR code image - if QR
  code was parsed, then a new tunnel will be added.
- Click "+" blue button, try to import an invalid QR code image - Error
  message will be shown

Signed-off-by: Nikita Pustovoi <deishelon@gmail.com>
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2022-03-06 10:48:15 -07:00
Harsh Shandilya 751ce54fa5 build: upgrade dependencies
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2022-03-03 11:53:18 +05:30
Michal Murin 72dc677819 tunnel: fix BadConfigExceptionTest
Fix the test by changing the DNS to a string with an invalid char in the
`invalid-value.conf` test configuration file.

Signed-off-by: Michal Murin <michal.murin@jamf.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2022-02-09 12:01:56 +01:00
Harsh Shandilya 7002367e4f gradle: update AndroidX dependencies
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2022-01-28 22:08:34 +05:30
Jason A. Donenfeld 5339e48251 ToolsInstaller: set id=wireguard magisk module param
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2022-01-21 17:10:28 +01:00
Marcel Joss d626e23210 ui: add margin on empty list text
Signed-off-by: Marcel Joss <marceljoss@hotmail.ch>
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2022-01-17 11:51:27 +05:30
Harsh Shandilya 342ed5e259 ui: make when statements exhaustive everywhere
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2022-01-08 15:30:12 +05:30
Harsh Shandilya 2bf09f8e2d gradle: bump AGP, Kotlin and AGP
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2022-01-08 15:30:11 +05:30
Harsh Shandilya 36d93a8e1b gradle: bump wrapper to 7.3.3
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2022-01-08 15:30:11 +05:30
Jason A. Donenfeld 1d7d306950 version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-10-29 17:21:43 +02:00
Jason A. Donenfeld 06306c669d README: re-add desugaring block
People are never gonna figure it out otherwise.

This reverts commit 1701e4fde4.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-10-29 17:19:00 +02:00
Jason A. Donenfeld d19e126e2e tools: bump libwg-go
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-10-29 16:58:28 +02:00
Jason A. Donenfeld bf84e26a86 global: bump copyright year
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-10-29 16:47:12 +02:00
Jason A. Donenfeld a03ad51622 tunnel: remove kernel module downloader
Nathan Chance dropped the ball repeatedly and never maintained this in a
consistent way that anybody could use. With Android 12 out now, just
drop it all together. A bummer, but I don't see much of a choice.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-10-29 16:42:36 +02:00
Harsh Shandilya 447b06ec2c ui: fix and silence lint errors
- The `copied_to_clipboard` translation for Farsi does not include
the placeholder, so it has been removed.

- A couple lints that are errors but we cannot particularly do anything about
were downgraded to warnings.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-10-28 03:19:56 +05:30
Harsh Shandilya 6da1d5ed01 tunnel: make JSR305 annotations a compileOnly dependency
These have no business being part of the runtime classpath of this library

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-10-28 03:19:55 +05:30
Harsh Shandilya 836c367499 gradle: upgrade AndroidX dependencies
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-10-28 03:19:55 +05:30
Harsh Shandilya 15cb99a41f strings: sync translations
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-10-27 18:56:52 +05:30
Harsh Shandilya fae74dd3ca ui: upgrade zxing-android-embedded
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-10-25 22:42:39 +05:30
Harsh Shandilya e462ae270d gradle: bump wrapper to 7.2
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-10-25 22:38:00 +05:30
Harsh Shandilya 24d5a28a4a gradle: bump AGP
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-10-25 22:27:34 +05:30
Harsh Shandilya 3df42898ae gradle: upgrade AndroidX dependencies
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-10-10 18:23:51 +05:30
Harsh Shandilya 1701e4fde4 README: link to Android desugaring docs
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-09-27 08:45:46 +05:30
Jason A. Donenfeld f6d175b774 strings: sync with crowdin
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-09-26 20:05:35 -06:00
Jason A. Donenfeld 878c450563 README: bump desugar version
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-09-26 18:40:30 -06:00
Jason A. Donenfeld b444ea064e version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-09-26 17:38:31 -06:00
Jason A. Donenfeld 4eb90266a2 tunnel: bump to work on x86_64 architecture
Bionic bans poll, so switch to ppoll. Folks were experiencing crashes on
ChromeOS.

We're waiting for https://go-review.googlesource.com/c/sys/+/352310 to
be merged, but for now we rely on
https://git.zx2c4.com/wireguard-go/commit/?id=fcc601dbf0f6b626ec1d47a880cbe64f9c8fe385

Reported-by: Rodrigo Alexandre <rdrslv00@gmail.com>
Reported-by: Mace Moneta <moneta.mace@gmail.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-09-26 17:35:57 -06:00
Jason A. Donenfeld 3935a369b8 ui,tunnel: support DNS search domains
wg-quick has supported this for a while, but not the config layer, and
not the Go backend, so wire this all up.

Requested-by: Alexis Geoffrey <alexis.geoffrey97@gmail.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-09-25 22:22:09 -06:00
Jason A. Donenfeld 32fc760053 version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-09-24 14:07:12 -06:00
Jason A. Donenfeld 5459c6d531 tools: bump deps
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-09-24 14:07:12 -06:00
Harsh Shandilya a1889b801c build: upgrade Kotlin and AndroidX dependencies
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-09-24 12:02:04 +05:30
Jason A. Donenfeld a86dff9433 tunnel: bump deps
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-09-13 16:39:46 +02:00
Jason A. Donenfeld 02f59b6b27 tools: bump for android 12
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-09-09 23:39:03 +02:00
Harsh Shandilya 29bb93cdf7 gradle: update property set with AGP 7 experimental flags
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-07-29 12:30:07 +05:30
Harsh Shandilya eae06aade7 build: fix CMake warning
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-07-29 11:21:26 +05:30
Harsh Shandilya a8b2fc15de strings: sync translations
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-07-29 11:21:24 +05:30
Harsh Shandilya f699d9cf9a build: switch to modern plugin application layout
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-07-29 10:12:04 +05:30
Harsh Shandilya ae00e8ce6e gradle: upgrade to AGP 7.0.0
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-07-29 10:12:03 +05:30
Harsh Shandilya 2730e75474 ui: mark app_name string as untranslatable
WireGuard is a brand name that should not be localized.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-07-29 10:11:34 +05:30
Harsh Shandilya 00e0224fd1 gradle: fix distribution checksum
This should've been updated when we switched the distribution type to -bin

Fixes: a23c57bab0 ("gradle: switch to -bin distribution")
Reported-by: Vladimir Nikishkin <lockywolf@gmail.com>
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-07-29 10:03:29 +05:30
Harsh Shandilya 82c9b75ea1 gradle: disable Jetifier that is no longer necessary
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-07-28 15:32:49 +05:30
Harsh Shandilya a23c57bab0 gradle: switch to -bin distribution
-all is a noticeably larger distribution than -bin and the sources
it packages can be fetched on-demand by IDEs.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-07-25 21:45:58 +05:30
Harsh Shandilya 02b92c178a build: upgrade AndroidX dependencies
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-07-25 21:45:57 +05:30
Harsh Shandilya 8dd6c3e35e build: upgrade AndroidX dependencies
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-07-18 02:24:23 +05:30
Harsh Shandilya 78f2fda6ca gradle: bump to 7.1.1
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-07-18 02:24:21 +05:30
Harsh Shandilya 2f822aa1f6 build: drop obsolete dependency substitution
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-06-16 10:37:23 +05:30
Harsh Shandilya 40f2f073cd gradle: bump to v7.1
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-06-16 08:59:53 +05:30
Harsh Shandilya 37fabf0229 build: bump desugar_jdk_libs and Kotlin
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-05-27 21:48:03 +05:30
Jason A. Donenfeld fe61522f2a tunnel: retry DNS resolution for 10 seconds
This has several problems: 1) it blocks the main thread; 2) it doesn't
distinguish between a permanent error and a transient one; 3) the 10
seconds is hard coded; 4) there's no way for the user to cancel it.

We'll have to improve this.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-05-26 18:07:28 +02:00
Harsh Shandilya 24ded8070f build: upgrade AndroidX dependencies
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-05-19 01:33:06 +05:30
Harsh Shandilya 24569a4c49 gradle: use longer timeouts for Gradle publish tasks
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-05-07 14:06:44 +05:30
Jason A. Donenfeld b448d605f0 version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-05-07 10:28:51 +02:00
Jason A. Donenfeld 0dcfde35f4 tunnel: bump deps
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-05-07 10:28:51 +02:00
Jason A. Donenfeld 6acc1125b8 tunnel: download hash list in chunks if necessary
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-05-07 10:25:10 +02:00
Jason A. Donenfeld 94ecb13d2f ui: update datastore and rework api
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-05-06 17:02:28 +02:00
Jason A. Donenfeld 6008efcd95 ui: remove hack for broken kotlin compiler
Seems like things are finally fixed.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-05-06 16:22:58 +02:00
Jason A. Donenfeld d6a8e9d4dc tunnel: avoid race between shutdown and stats
wgTurnOff can block for a while, in which case, calling getStatistics
will use a stale handle and stale tunnel. Not only that, but wgGetConfig
might return null, in which case string.split throws.

    java.lang.NullPointerException: Attempt to invoke virtual method
    'java.lang.String[] java.lang.String.split(java.lang.String)' on a null
    at com.wireguard.android.backend.GoBackend.getStatistics

Reported-by: tomt@adslweb.co.uk
Link: https://lists.zx2c4.com/pipermail/wireguard/2021-May/006709.html
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-05-06 10:50:20 +02:00
Jason A. Donenfeld bcd8c33005 version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-05-05 13:30:28 +02:00
Harsh Shandilya e71c84a785 ui: replace deprecated string operations
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-05-05 16:56:56 +05:30
Jason A. Donenfeld 3474849b1d project: use kotlin official code style
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-05-05 13:19:04 +02:00
Jason A. Donenfeld f32c5cc222 tools: bump deps
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-05-05 13:02:56 +02:00
Harsh Shandilya cf6e1490f4 build: update AGP, Kotlin and AndroidX Lifecycle
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-05-05 12:29:23 +05:30
Harsh Shandilya 86951f509c build: bump fragment to 1.3.3
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-04-22 01:22:38 +05:30
Harsh Shandilya 8e9b2c6f05 ui: abstract out theme attributes to reduce overlap
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-04-21 17:17:42 +05:30
Harsh Shandilya 9ace8dd928 strings: replace three dots with ellipsis character
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-04-21 17:17:42 +05:30
Harsh Shandilya 8f727903f3 ui: remove unnecessary v21 styles override
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-04-21 17:17:42 +05:30
Harsh Shandilya b6aa09bc19 strings: remove invalid translation from Farsi
copied_to_clipboard is a format string and must have a format specifier

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-04-21 17:17:41 +05:30
Harsh Shandilya 782550318a ui: remove some more non-null assertions on binding fields
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-04-21 17:17:41 +05:30
Harsh Shandilya d02543639b ui: reduce size of QS tile drawable
This will be rendered on an even smaller scale on devices, but
400dp x 400dp was simply too big and could cause performance issues.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-04-21 17:17:38 +05:30
Harsh Shandilya e1e16cdf3b strings: fix resource qualifier for Indonesian
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-04-21 16:31:12 +05:30
Harsh Shandilya 1bbcf83f43 TunnelListFragment: drop incorrect non-null assertion
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-04-21 16:25:12 +05:30
Harsh Shandilya 169bd408f2 gradle: bump wrapper to v7.0
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-04-11 22:03:25 +05:30
Harsh Shandilya 777e3b71ba strings: sync translations
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-04-11 21:52:27 +05:30
Harsh Shandilya 511e54764e build: bump to Kotlin 1.4.32
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-03-30 11:26:44 +05:30
Harsh Shandilya d0b5fb5107 build: upgrade dependencies
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-03-29 12:58:50 +05:30
Harsh Shandilya 7c3137e2c8 gradle: include mavenCentral in plugin search repositories
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-03-29 12:53:55 +05:30
Harsh Shandilya 12a3ec28bc build: remove JCenter repository
Force trove4j to be resolved from the newer coordinates used by AGP 7.0

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-03-16 14:31:51 +05:30
Harsh Shandilya 892295c42a build: upgrade AndroidX activity and fragment
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-03-11 10:04:22 +05:30
Harsh Shandilya ea9ef4af24 build: upgrade Kotlin and turn on IR compiler
Kotlin has been building a new JVM backend for a while now
and it is finally in Beta, scheduled to hit stable in Kotlin 1.4.50.
This is the time to enable it and report any bugs we hit, before it
becomes the default.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-03-01 15:54:54 +05:30
Harsh Shandilya b8870f3599 build: upgrade to Gradle 6.8.3
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-02-23 17:08:01 +05:30
Jason A. Donenfeld 11301617d2 tunnel: update to go 1.16 and newer api
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-02-22 15:27:53 +01:00
Harsh Shandilya 617be576f8 build: upgrade to ZXING 4.1.0
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-02-19 19:30:17 +05:30
Jason A. Donenfeld 8523979c9c tunnel: report git commit as wgVersion
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-02-12 18:08:38 +01:00
Jason A. Donenfeld 8768acee68 README: move tunnel to maven central
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-02-12 17:37:31 +01:00
Harsh Shandilya a73d2121e1 build: update MDC to 1.3.0 stable release
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-02-11 22:34:43 +05:30
Harsh Shandilya dd58fad69e build: upgrade to Kotlin 1.4.30
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-02-11 22:33:17 +05:30
Harsh Shandilya ba9d689ef9 build: upgrade AndroidX libraries to stable versions
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-02-11 22:33:04 +05:30
Harsh Shandilya 97d82740d0 gradle: fix the distribution checksum
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-02-11 22:30:38 +05:30
Jason A. Donenfeld 0750c29c7f version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-02-11 16:40:34 +01:00
Jason A. Donenfeld 639ee6b5b2 tunnel: add developer information to pom xml
Otherwise sonatype gets upset.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-02-11 16:40:34 +01:00
Jason A. Donenfeld f764f2aaa9 build: update AGP to 4.1.2
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-02-11 16:11:57 +01:00
Jason A. Donenfeld d2a9c56d9c gradle: remove bad checksum from properties
The hash was wrong, causing crashes. Android studio told me to remove it
so I did. I don't quite like that, but I don't know how Harsh came up
with the previous hash.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-02-11 16:10:28 +01:00
Jason A. Donenfeld 4c3289aa52 tunnel: bump all tools
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-02-11 16:00:28 +01:00
Jason A. Donenfeld 79376bca64 tunnel: sign using gpg-agent
This way we don't have to have a separate java universe.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-02-11 15:55:20 +01:00
Harsh Shandilya b709d36c01 tunnel: switch publishing to MavenCentral
Since MavenCentral requires GPG signed artifacts, we'll need to configure
some things on the machine running the deployment. Specifically, these
three Gradle properties need to be set (preferably in ~/.gradle/gradle.properties)

```
signing.keyId= // Duh
signing.password= // I have absolutely no idea how this will work with HSMs
signing.secretKeyRingFile= // $HOME/.gnupg/... you know the deal
```

The BINTRAY_USER and BINTRAY_KEY variables are replaced by SONATYPE_USER
and SONATYPE_PASSWORD to better reflect their new contents.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-02-11 01:58:41 +05:30
L.W.Reek 0301c85e2c build: include org.jetbrains.trove4j from jcenter
mavenCentral does not have org.jetbrains.trove4j which causes the
build to fail.

* What went wrong:
Execution failed for task ':tunnel:extractReleaseAnnotations'.
> Could not resolve all files for configuration ':tunnel:lintClassPath'.
   > Could not find org.jetbrains.trove4j:trove4j:20160824.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/org/jetbrains/trove4j/
         trove4j/20160824/trove4j-20160824.pom
       - https://repo.maven.apache.org/maven2/org/jetbrains/trove4j/
         trove4j/20160824/trove4j-20160824.pom
     Required by:
         project :tunnel > com.android.tools.lint:lint-gradle:27.1.1 >
                  com.android.tools:sdk-common:27.1.1
         project :tunnel > com.android.tools.lint:lint-gradle:27.1.1 >
                  com.android.tools.external.com-intellij:intellij-core:27.1.1

Fixes: 13cc4436ca ("build: switch to mavenCentral as the main repository")
Signed-off-by: L.W.Reek <syphyr@gmail.com>
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-02-10 18:31:36 +05:30
Harsh Shandilya 7e979817e2 build: upgrade to Gradle 6.8.2
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-02-05 22:25:52 +05:30
Harsh Shandilya 13cc4436ca build: switch to mavenCentral as the main repository
Retain JCenter but restrict it the single dependency we require off it

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-02-05 22:25:38 +05:30
Harsh Shandilya bcfbf37ed1 build: update fragment to 1.3.0-rc02
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-02-03 13:33:47 +05:30
Jason A. Donenfeld 74ff870cf5 tunnel: bump libwg-go and use newer logging function
We also plug a memory leak. C.CString was calling malloc, and these were
never freed.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-01-27 01:10:48 +01:00
Harsh Shandilya b4f54e8958 strings: sync translations
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-01-23 14:59:00 +05:30
L.W.Reek d179a3af15 libwg-go: update to go 1.15.6
Signed-off-by: L.W.Reek <syphyr@gmail.com>
2021-01-23 14:42:46 +05:30
Harsh Shandilya 2bac2feeb5 build: upgrade runtime dependencies
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-01-23 14:33:00 +05:30
Harsh Shandilya 261236c8ce gradle: bump wrapper to v6.8.1
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2021-01-23 14:01:44 +05:30
Jason A. Donenfeld 4a7969ef24 ClipboardUtils: localize clipboard notification snack
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-01-01 16:34:03 +01:00
Jason A. Donenfeld f670ff22c6 version: bump
A Christmas eve special.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-12-24 14:30:11 +01:00
Jason A. Donenfeld cb3194f10a tunnel: bump libwg-go
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-12-23 22:55:56 +01:00
Jason A. Donenfeld f6b2bbf433 strings: sync with crowdin
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-12-21 17:52:24 +01:00
Harsh Shandilya 56a4862442 build: upgrade to MDC 1.3.0-beta01
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-12-17 14:22:43 +05:30
Jason A. Donenfeld 20390d65c8 version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-12-16 19:09:21 +01:00
Jason A. Donenfeld 177457e67b tunnel: bump libwg-go
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-12-16 19:04:17 +01:00
Harsh Shandilya 8caec4d739 build: downgrade Jetpack Datastore to 1.0.0-alpha02
We're hitting occasional build failures with the newer versions that have not been triaged yet

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-12-16 19:03:43 +01:00
Harsh Shandilya fb819b99a4 build: upgrade AGP, Kotlin, core-ktx and mdc-android
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-12-16 18:55:08 +01:00
Harsh Shandilya fe82037f06 build: upgrade activity and fragment to latest betas
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-12-16 18:55:08 +01:00
Harsh Shandilya c2aa1b21f8 build: upgrade datastore dependency
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-12-03 01:26:48 +05:30
Harsh Shandilya d69415b55a build: upgrade dependencies
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-11-30 22:38:17 +05:30
Harsh Shandilya 4fae2d1255 ui: show all apps with internet permission in exclusions list
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-11-16 15:45:19 +05:30
Jason A. Donenfeld a300f269f1 ui: test for any camera, not just rear one
Some folks use chromebooks, which don't have rear cameras.

Reported-by: Jay Tuley <jay.tuley@ekonbenefits.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-10 14:11:48 +01:00
Harsh Shandilya 961cba3f7c build: upgrade runtime dependencies
Updates ConstraintLayout, kotlinx.coroutines, Jetpack DataStore, JUnit and Lifecycle-Runtime-KTX

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-11-09 17:01:54 +05:30
Harsh Shandilya 6bc7386bff strings: sync translations
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-11-07 19:13:43 +05:30
Harsh Shandilya 5fa08f286e build: add task to sync localisations with Crowdin
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-11-07 19:13:42 +05:30
Harsh Shandilya 35f868733c build: switch to Gradle's maven-publish plugin
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-11-07 18:53:06 +05:30
Jason A. Donenfeld e71b3d2583 ToolsInstaller: unbreak cleanup
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-10-27 13:35:07 +01:00
Jason A. Donenfeld 755148242c tunnel: do not constantly raise toasts when process is opportunistically killed
Modern Android likes to kill processes to free ram and resources. When
kernel-mode WireGuard is in use, this is quite alright with us, since
the app doesn't actually need to consume any resources at all in order
for the tunnel to run. So, we want to allow and encourage this resource
frugality. However, when the quick settings tile is being used or when
the app is referenced otherwise, the app will occasionally be restarted,
to, for example, repaint the quick settings tile. This is also fine, as
the process winds up being short-lived again. But, since process
initialization means asking for a new root shell in order to check on
kernel-mode WireGuard, this means that Magisk raises a systemwide toast.
On some phones, this happens each and every time that the notification
shade is pulled down. It's not only annoying but it sometimes obscures
other notifications that users want to see, prompting their pulling down
of the notification shade in the first place. In order to get rid of
this nuisance, just disable these notifications and extraneous logs, so
that we don't clutter the system every time that the process is
opportunistically killed and restarted.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-10-26 22:44:35 +01:00
Jason A. Donenfeld 15fea6f02f tunnel: clean up some docstring wording
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-10-20 16:35:05 +02:00
Harsh Shandilya cb2842e8ef build: upgrade to Gradle 6.7
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-10-15 10:01:53 +05:30
Jason A. Donenfeld 106b67d892 build: add crowdin syncer script and use it
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-10-14 17:16:36 +02:00
Harsh Shandilya 996587f792 build: update to AGP 4.1.0
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-10-13 16:18:49 +02:00
Jason A. Donenfeld 3a4bf35c77 README: mention desugaring
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-10-08 15:03:49 +02:00
Harsh Shandilya 46b37c0c26 build: update AGP and ConstraintLayout
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-10-07 14:14:38 +05:30
Jason A. Donenfeld 5b5ba88a97 tunnel: use more subtle roaming escape hatch
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-10-07 10:21:02 +02:00
Jason A. Donenfeld ceb3095a0a build: update to mdc 1.3.0-alpha03
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-10-05 21:46:03 +02:00
Jason A. Donenfeld a31f0cf788 DownloadsFileSaver: initialize callback in constructor, not on the fly
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-10-02 12:11:48 +02:00
Jason A. Donenfeld 1dc74b171c build: upgrade AndroidX biometric
The BiometricConstants class was removed and these were folded into
BiometricPrompt.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-10-02 11:35:53 +02:00
Harsh Shandilya 9266487fe5 build: update AndroidX activity/fragments and resolve compile failure
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-10-02 04:28:25 +05:30
Harsh Shandilya 5d7ce139bc ui: use commit extension from fragment-ktx
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-09-30 22:42:05 +05:30
Jason A. Donenfeld ddb6c87ebf ui: account for binding disappearing on detail fragment
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-30 12:47:29 +02:00
Jason A. Donenfeld 8a6f8f73cd version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-27 16:30:30 +02:00
Jason A. Donenfeld f4fc15538d tv: hack gridlayoutmanager to fill columns before row if we're not scrolling
If we're horizontally scrolling, it makes sense to fill rows before
columns. But if it all fits in one page and we don't need to scroll
horizontally, it looks ridiculous. So, in this case, rearrange the tiles
so that it appears to fill columns before rows. But we don't want things
suddenly jumping around, so actually, keep the same ordering as
rows-before-columns, but add invisible spaces after certain items, so
that the fill area makes it look as though it's columns-before-rows.
This winds up being much more visually pleasing.

We do this by figuring out this kind of transformation:

If we convert this matrix:

	0 3 6
	1 4 _
	2 5 _

To this one:

	0 2 4 6
	1 3 5 _
	_ _ _ _

For a given index, how many spaces are under it? This changes depending
on how many total are in a grid. Going from 3x3 to 4x3, for example, we
have:

	count == 12, index =
	count == 11, index = 10
	count == 10, index = 7,9
	count == 9, index = 4,6,8
	count == 8, index = 1,3,5,7
	count == 7, index = 1,3,5,6!
	count == 6, index = 1,3,4!,5!
	count == 5, index = 1,2!,3!,4!
	count == 4, index = 0!,1!,2!,3!
	count == 3, index = 0!,1!,2!
	count == 2, index = 0!,1!
	count == 1, index = 0!
	count == 0, index =

The '!' means two blanks below, no '!' means one blank below, and no
mention means no blanks below.

This commit adds code to compute such a table on the fly.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-27 13:17:56 +02:00
Jason A. Donenfeld 938399d881 ui: queue up tunnel mutating on activity scope instead of fragment scope
Fragment scopes get cancelled when the fragment goes away, but we don't
actually want to cancel an in-flight transition in that case. Also,
before when the fragment would cancel, there'd be an exception, and the
exception handler would call Fragment::getString, which in turn called
requireContext, which caused an exception. Work around this by using the
`activity ?: Application.get()` idiom to always have a context for
strings and toasts.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-26 13:49:14 +02:00
Jason A. Donenfeld 53ca421a85 ui: print proper exception trace from log viewer
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-26 12:01:58 +02:00
Jason A. Donenfeld 32778d1c03 ui: request intent permissions from hidden activity
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-26 11:44:24 +02:00
Jason A. Donenfeld a870bf6e04 version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-24 14:12:51 +02:00
Jason A. Donenfeld 7a8f708157 tv: handle going up directories better
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-24 14:12:40 +02:00
Jason A. Donenfeld e729c5dc51 tv: show volume descriptions for file picker
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-24 14:12:40 +02:00
Jason A. Donenfeld 4bf34c49b7 ui: account for null data in callback
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-24 14:12:40 +02:00
Jason A. Donenfeld 05511d4900 ui: cleanup code after churn
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-23 17:56:37 +02:00
Jason A. Donenfeld 15da17b595 tv: use system picker for API 29+
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-23 17:56:37 +02:00
Jason A. Donenfeld b3c43e428f tv: use our own file picker
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-23 17:56:37 +02:00
Jason A. Donenfeld 7bec539722 tv: escape deletion view with back button
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-23 17:56:37 +02:00
Jason A. Donenfeld a8dfebb086 tv: select first item after toggling deletion mode
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-22 23:59:40 +02:00
Jason A. Donenfeld e72b4fc144 tv: hook up isFocused as observable property
This is kind of ridiculous, since the items own state should clearly be
queryable, but it doesn't appear to be the case here, so just shuffle it
around into kotlin and back.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-22 23:54:41 +02:00
Jason A. Donenfeld 03189e7b20 tv: add text when there are no tunnels
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-22 23:54:38 +02:00
Jason A. Donenfeld 10bb413187 tv: make cards slightly smaller
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-22 23:54:36 +02:00
Jason A. Donenfeld 1c814310b9 tv: select the right thing on load
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-22 23:54:32 +02:00
Harsh Shandilya 3fe9e3162f tv: tweak TV layout to fit 3 rows better
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-09-22 23:54:30 +02:00
Harsh Shandilya 6da6f7886a tv: set layout manager from XML
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-09-22 23:54:26 +02:00
Jason A. Donenfeld 8c2029870f tv: make logo almost better
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-22 23:54:23 +02:00
Harsh Shandilya a5031a44a0 tv: anchor RV bottom to top of delete button
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-09-22 23:54:20 +02:00
Jason A. Donenfeld 44b27fe472 tv: remove useless attribute
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-22 23:54:17 +02:00
Jason A. Donenfeld 93fb3b345b tv: use plus instead of text for importing
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-22 23:54:14 +02:00
Harsh Shandilya 8b596697b7 tv: do theming
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-09-22 23:54:04 +02:00
Jason A. Donenfeld c536bbb7e9 tv: account for broken TVs with no file picker
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-22 23:54:01 +02:00
Jason A. Donenfeld a978aac129 tv: remove tiny words from tv banner
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-22 23:53:57 +02:00
Jason A. Donenfeld eb8cab4110 tv: do not redisplay stats when deleting
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-22 23:53:54 +02:00
Jason A. Donenfeld 0a36d9a5e9 tv: add tv banner
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-22 23:53:51 +02:00
Jason A. Donenfeld 309571039d tv: use proper icon for button
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-22 23:53:49 +02:00
Jason A. Donenfeld d56f2fb1bb tv: hide deletion button when nothing to delete
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-22 23:53:47 +02:00
Jason A. Donenfeld 9df8e5e239 tv: add ugly deletion mode
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-22 23:53:44 +02:00
Jason A. Donenfeld 444a86cc9f tv: wire in stats
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-22 23:53:40 +02:00
Jason A. Donenfeld 382e10e103 tv: wire up tunnel start/stop
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-22 23:53:37 +02:00
Jason A. Donenfeld dc002d77fa tv: begin to wire up databindings
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-22 23:53:32 +02:00
Jason A. Donenfeld aaa55c0dcc tv: abstract out tunnel importing
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-22 23:53:30 +02:00
Harsh Shandilya 0ad3781ae5 tv: initial draft of Android TV support
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-09-22 23:53:27 +02:00
Jason A. Donenfeld d738161a2e Statistics: only do one hash lookup
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-21 11:16:33 +02:00
Jason A. Donenfeld 52c2e9cd24 TunnelManager: catch exception in intent receiver
java.lang.IllegalStateException:
  at android.app.ContextImpl.startServiceCommon (ContextImpl.java:1720)
  at android.app.ContextImpl.startService (ContextImpl.java:1675)
  at android.content.ContextWrapper.startService (ContextWrapper.java:669)
  at com.wireguard.android.backend.GoBackend.startVpnService (GoBackend.java:4)
  at com.wireguard.android.backend.GoBackend.setStateInternal (GoBackend.java:4)
  at com.wireguard.android.backend.GoBackend.setState (GoBackend.java:2)
  at com.wireguard.android.model.TunnelManager$setTunnelState$2$1.invokeSuspend (TunnelManager.java:6)
  at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (BaseContinuationImpl.java:2)
  at kotlinx.coroutines.DispatchedTask.run (DispatchedTask.java:2)
  at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely (CoroutineScheduler.java)
  at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask (CoroutineScheduler.java:7)
  at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker (CoroutineScheduler.java:7)
  at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run (CoroutineScheduler.java:7)

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-21 10:54:07 +02:00
Jason A. Donenfeld 5fd1a32ae4 TunnelEditorFragment: do not assume a context
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-20 18:08:58 +02:00
Jason A. Donenfeld 655a853857 TunnelListFragment: do not assume binding always exists
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-20 18:05:43 +02:00
Jason A. Donenfeld 847da23300 TunnelDetailFragment: use kotlin coroutine for timer and rework nullability
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-20 18:03:58 +02:00
Jason A. Donenfeld d5c07374ff BaseFragment: avoid using requireContext() in permission result callback
java.lang.IllegalStateException:
  at androidx.fragment.app.Fragment.requireContext (Fragment.java:17)
  at com.wireguard.android.fragment.BaseFragment$setTunnelStateWithPermissionsResult$1.invokeSuspend (BaseFragment.java:4)
  at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (BaseContinuationImpl.java:2)
  at kotlinx.coroutines.UndispatchedCoroutine.afterResume (UndispatchedCoroutine.java:19)
  at kotlinx.coroutines.AbstractCoroutine.resumeWith (AbstractCoroutine.java:13)
  at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (BaseContinuationImpl.java:2)
  at kotlinx.coroutines.UndispatchedCoroutine.afterResume (UndispatchedCoroutine.java:19)
  at kotlinx.coroutines.AbstractCoroutine.resumeWith (AbstractCoroutine.java:13)
  at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (BaseContinuationImpl.java:2)
  at kotlinx.coroutines.DispatchedTask.run (DispatchedTask.java:2)
  at android.os.Handler.handleCallback (Handler.java:790)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loop (Looper.java:164)
  at android.app.ActivityThread.main (ActivityThread.java:7025)
  at java.lang.reflect.Method.invoke (Method.java)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:441)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1408)

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-20 15:01:35 +02:00
Jason A. Donenfeld 3785752364 version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-20 12:50:11 +02:00
Jason A. Donenfeld 398d8a1e41 AddTunnelsSheet: disable qrcode scanning if no camera
Part of the enhancements for Android TV.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-20 12:47:13 +02:00
Harsh Shandilya dfd8ca6f79 ui: add tooling label for exclusions button
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-09-20 13:33:48 +05:30
Harsh Shandilya 7cff4367d7 ui: add navigation hints for D-Pad and IME
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-09-20 13:33:48 +05:30
Jason A. Donenfeld 9eaed5e745 version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-18 20:29:23 +02:00
Harsh Shandilya 68350bb4df ui: add xhdpi banner resource
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-09-18 20:29:23 +02:00
Jason A. Donenfeld 12be972fcd SettingsActivity: account for module present but no root
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-18 20:29:23 +02:00
Jason A. Donenfeld d200437813 ui: move to Jetpack DataStore instead of SharedPrefs
Hopefully PreferencesPreferenceDataStore gets to go away sometime down
the line.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-18 20:29:23 +02:00
Jason A. Donenfeld 3ffe7a5e68 ui: reformat code
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-18 14:55:27 +02:00
Jason A. Donenfeld 08ff9f5ece gradle: downgrade androidx.{fragment,activity} to alpha07
The alpha08 version introduced regressions that we can't deal with at
the moment.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-17 23:47:14 +02:00
Harsh Shandilya 4bee579e48 ui: retire EdgeToEdge
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-09-17 23:09:05 +05:30
Harsh Shandilya a906c478c9 ui: replace deprecated onActivityCreated with onViewCreated
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-09-17 20:00:37 +05:30
Harsh Shandilya 306d0648c6 ui: refactor AddTunnelsSheet's selection communication
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-09-17 19:36:44 +05:30
Harsh Shandilya e99ccf9013 ui: refactor AppListDialogFragment's selection communication
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-09-17 14:51:50 +02:00
Jason A. Donenfeld 59935a12b9 activityx: use contracts more and refine
This is the beginning; there are still many of the old API's callsites
to convert.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-17 14:50:37 +02:00
Jason A. Donenfeld a9ec828506 DownloadsFileSaver: encapsulate permission checks
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-17 14:50:37 +02:00
Jason A. Donenfeld eebeece856 LogViewerActivity: simplify scoping
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-16 18:01:06 +02:00
Jason A. Donenfeld 746ab00794 ZipExporterPreference: don't ask for storage permissions on newer android
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-16 18:01:06 +02:00
Jonathan Davies b877593d55 libwg-go: use PeekLookAtSocketFd6(), not PeekLookAtSocketFd4()
Signed-off-by: Jonathan Davies <jpds@protonmail.com>
Fixes: 3d088411 ("libwg-go: use conn.Bind for socketfd peek")
Cc: David Crawshaw <crawshaw@tailscale.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-16 18:01:06 +02:00
Harsh Shandilya dcd596907a ui: resolve getColor deprecation in LogViewerActivity
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-09-16 18:01:06 +02:00
Jason A. Donenfeld 44c2afbfba LogViewerActivity: destroy process when coroutine scope is cancelled
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-16 18:01:06 +02:00
Harsh Shandilya bd1679b7e0 ui: await activity creation to change selected tunnel
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-09-16 18:01:06 +02:00
Harsh Shandilya ff7d7e0edd tunnel: document more public API from backend package
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-09-16 18:01:06 +02:00
Harsh Shandilya 2f088938c6 ui: replace GlobalScope with a hand-rolled CoroutineScope
GlobalScope has numerous problems[1] that make it unfit for
use in most applications and making it behave correctly requires
an excessive amount of verbosity that's alleviated simply by using
any other scope. Since we run multiple operations in the context
of the application's lifecycle, introduce a new scope that is created
when our application is, and cancelled upon its termination.

While at it, make the scope default to Dispatchers.IO to reduce pressure
on the UI event loop. Tasks requiring access to the UI thread appropriately
switch context making the change completely safe.

1: https://medium.com/@elizarov/the-reason-to-avoid-globalscope-835337445abc

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-09-16 18:01:06 +02:00
Jason A. Donenfeld 53adb0e9a6 Ed25519: use implementation from Tink
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-16 18:01:06 +02:00
Harsh Shandilya 6789c11a7b ConfigNamingDialogFragment: fix focus request for config naming dialog
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-09-16 18:01:06 +02:00
Jason A. Donenfeld c56065fcfe TunnelEditorFragment: move backwards using fragment manager instead of hack
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-16 18:01:06 +02:00
Jason A. Donenfeld 52a2ae36f6 TunnelEditorFragment: avoid extra trip through event loop
onSelectedTunnelChanged is already queueing us to Dispatchers.Main
(rather than Dispatchers.Main.immediate, which would crash, but why?),
so avoid the extra trip through the event loop by toggling the selected
tunnel right away.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-16 10:51:56 +02:00
Jason A. Donenfeld abcb51d2a6 Extensions: use more idiomatic kotlin
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-16 10:44:50 +02:00
Jason A. Donenfeld 8b9a40b3d7 global: lint codebase with recent changes
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-16 10:37:21 +02:00
Harsh Shandilya 4b36df504c ui: don't use low-level logger API
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-09-16 13:04:42 +05:30
Harsh Shandilya 35fe5bd5f0 ui: update manifest for API 30 changes
- Mark WRITE_EXTERNAL_STORAGE as unused above API 29 since we defer to Storage Access Framework on P and above

- Adds a <queries> tag to allow listing apps for exclusion/inclusion dialog

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-09-16 10:20:10 +05:30
Jason A. Donenfeld 79ae85c728 coroutines: lifecycleScope is by default on Main.immediate
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-16 00:00:31 +02:00
Jason A. Donenfeld 49ac61304e coroutines: use lifecycleScope where appropriate
There's still a bit of GlobalScope lingering around, which might be
removable.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-15 23:46:11 +02:00
Jason A. Donenfeld d79cdb0d41 MonkeyedTextInputEditText: au revoir
Remember to go back to using com.google.android.material when
1.3.0-alpha03 comes out.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-15 18:53:30 +02:00
Jason A. Donenfeld a3726b07bf wireguard-tools: bump to fix invalid free
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-15 16:21:09 +02:00
Jason A. Donenfeld 80c35a2053 TunnelListFragment: set selection on Main, not Main.immediate
Otherwise, we crash when saving the config.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-15 16:07:16 +02:00
Jason A. Donenfeld 601b58b670 libwg-go: update to go 1.15.2
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-15 13:40:13 +02:00
Jason A. Donenfeld 9cf049775f MonkeyedTextInputEditText: add note about sunset plan
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-15 12:44:55 +02:00
Jason A. Donenfeld 92122e60c6 idea: import new import sorting rules
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-15 12:30:15 +02:00
Jason A. Donenfeld f20d0f0659 gradle: desugar retrofuture and remove old deps
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-15 12:30:15 +02:00
Jason A. Donenfeld 9346a63753 gradle: do not use retrofuture in ui
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-15 12:30:15 +02:00
Jason A. Donenfeld bab70ab51e coroutines: convert the rest
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-15 12:30:15 +02:00
Jason A. Donenfeld 2fc0bb1a03 coroutines: convert low-hanging fruits
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-09-14 14:40:10 +02:00
Harsh Shandilya dd0ff8fe60 ui: remove hacky manual check for keyguard
Setting the correct value for the allowedAuthenticators field lets the library correctly detect this by itself as verified on an API 21 emulator

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-09-13 18:34:17 +05:30
Harsh Shandilya 45a179580d ui: update BiometricAuthenticator for API changes
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-09-13 18:33:17 +05:30
Harsh Shandilya 0bcee7f9cc ui: fix memory leak from statically held Handler instance
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-09-13 17:52:14 +05:30
Harsh Shandilya af10b117b4 build: uprev dependencies and fix script block order
- buildscript must always be the first block in a Gradle build

- ConstraintLayout, Kotlin and bintray plugin are updated to their latest stable revisions

- Biometrics is updated to the latest alpha release to make use of multiple memory leak fixes that plague the 1.0.x implementations

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-09-13 17:51:30 +05:30
Harsh Shandilya 7aa7825209 build: update to Gradle 6.6.1
While praying F-Droid gets their shit together by the time we do our next release

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-08-30 23:23:04 +05:30
Harsh Shandilya 8b7617294e tools: bump for Android 11 ndc fix
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-08-26 18:59:57 +05:30
Harsh Shandilya 9985b9b08e build: target SDK 30
We're all set to support it from the application side of things.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-08-25 21:17:05 +05:30
Harsh Shandilya 840d65881e build: switch fragment and preference to -ktx artifacts
Google recommends all dependencies with -ktx variants depend on them directly since they transitively pull in the main artifacts and offer extensions for better usage from Kotlin

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-08-23 01:07:27 +05:30
Harsh Shandilya c18f6818e8 build: uprev core-ktx and material components
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-08-23 01:07:26 +05:30
Harsh Shandilya dcd91cad1b ui: fix SDK 30 deprecation warning for implicit Looper in Handler init
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-08-23 01:03:49 +05:30
Harsh Shandilya 898bb679d2 ui: also enable StrictMode thread policy in debug builds
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-08-23 01:03:48 +05:30
Harsh Shandilya 348d430cd3 build: remove explicit buildToolsVersion
AGP sets it automatically, let's rely on that

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-08-23 00:49:11 +05:30
Harsh Shandilya e3d98633fb build: update AndroidX dependencies
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-08-23 00:43:25 +05:30
Harsh Shandilya b451920408 build: uprev to Kotlin 1.4
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-08-23 00:43:14 +05:30
Harsh Shandilya 1fa15e76e3 build: minor cleanups and reorganization
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-08-23 00:42:51 +05:30
Harsh Shandilya 8a58270e03 build: uprev to Gradle 6.6
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-08-12 13:28:00 +05:30
Jason A. Donenfeld e08d873cc3 version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-07-24 09:50:31 +02:00
Jason A. Donenfeld 3748a1da88 AdminKnobs: allow enterprise admins to disable private key export
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-07-23 17:35:47 +02:00
Jason A. Donenfeld 9597d719ac build: bump AGP to 4.0.1
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-07-23 16:04:22 +02:00
Harsh Shandilya 041ce2134f build: upgrade to Gradle 6.5.1
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-07-10 15:07:54 +05:30
Harsh Shandilya 4c17fc51e7 gitignore: add gradlew.bat
We do not support building on Windows for now and deleting this file on every wrapper update is just lame

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-06-25 01:36:31 +05:30
Harsh Shandilya 6cf7439053 gradle: upgrade to 6.5
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-06-25 01:36:30 +05:30
Harsh Shandilya 814ab4937d build: bump core-ktx, coroutines and fragments
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-06-25 01:30:00 +05:30
David Crawshaw 3d088411e2 libwg-go: use conn.Bind for socketfd peek
Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-06-22 02:24:55 -06:00
Jason A. Donenfeld 39e0c861e2 tools: bump versions
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-06-07 01:58:02 -06:00
Harsh Shandilya d60efcd7c7 strings: sync translations
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-06-02 17:52:01 +05:30
Harsh Shandilya 4dff537d21 ui: address new databinding requirements
Layouts in differing configurations must agree on their root tags, so we give
both copies of main_activity the same root ID, and adjust the check for
two-pane layout to simply test for nullability. This also changes the inset
dispatch code to use ViewCompat and WindowInsetsCompat since they will adjust
insets based on the SDK level allowing us to abstract away that concern.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-05-29 12:25:52 +05:30
Harsh Shandilya 761c2ade4a build: bump to AGP 4.0.0
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-05-29 12:05:24 +05:30
Harsh Shandilya 115a87af32 ui: remove unneeded actionBarPopupTheme attribute
This caused inconsistencies between our overflow icon and actionbar title's tint

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-05-09 15:49:43 +05:30
Harsh Shandilya c7ecaeb145 build: upgrade to gradle 6.4 and track checksum
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-05-09 13:15:57 +05:30
Jason A. Donenfeld 8e2d63db75 tunnel: add windows-style killswitch semantics for GoBackend
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-05-04 02:30:44 -06:00
Harsh Shandilya 3208bac987 build: upgrade to mdc-android 1.2.0-alpha06
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-04-30 18:21:31 +05:30
Harsh Shandilya fc1f2132fe build: bump gradle wrapper version in task configuration
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-04-27 14:09:37 +05:30
Harsh Shandilya 09125e1e31 libwg-go: bump go version
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-04-26 04:33:41 +05:30
Harsh Shandilya 6b1164ad8d ui: switch up dark theme system bars colors
The status bar color had a subtle transparency applied which caused
inconsistencies, and the navigation bar color was the wrong shade of
gray.

Reported-by: Danny Lin <danny@kdrag0n.dev>
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-04-26 04:30:26 +05:30
Harsh Shandilya c68a5c776b build: bump threetenabp to 1.2.4
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-04-24 19:32:36 +05:30
Harsh Shandilya f3ac787f5a ToolsInstaller: update Magisk directory
/data/adb/modules has been the location for modules since v18.0 and nobody
should reasonably be on any older version anymore. This has continued to
work for this long because Magisk created symlinks for backwards compat. However,
these symlinks are not created anymore on Android 11, which is where this
problem	first surfaced.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-04-23 01:40:50 +05:30
Harsh Shandilya 751be2c469 build: don't obfuscate code in minify step
While Play Console correctly manages to deobfuscate stacktraces using the
ProGuard mapping, it makes user recorded logs useless which is rather
undesirable.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-04-21 21:36:59 +05:30
Harsh Shandilya cfb7f1b016 ui: tweak fab animation duration
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-04-19 02:17:27 +05:30
Harsh Shandilya 33e07628db build: remove unused cardview dependency
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-04-19 02:09:07 +05:30
Harsh Shandilya b1b7d1d90c build: upgrade AGP, Kotlin, and preference
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-04-19 02:08:41 +05:30
Harsh Shandilya 6cb9548f72 tunnel: disable LongLogTag lint
Should have been part of the patch that disabled this for ui/

Fixes: 8d128cf2e9 ("ui: disable LongLogTag lint")
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-04-19 01:59:51 +05:30
Harsh Shandilya 8207ae1e8d strings: sync translations
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-04-19 01:48:50 +05:30
Harsh Shandilya 48e0e427eb ui: animate fab scale rather than translation
Suggested-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-04-16 23:14:35 +05:30
Jason A. Donenfeld 03e95d2dd3 ObservableTunnel: account for race in renulling stats
The stats might become null between these two checks, when a tunnel
flips off, resulting in a null pointer dereference:

at com.wireguard.android.model.ObservableTunnel.getStatisticsAsync (ObservableTunnel.java:103)
at com.wireguard.android.fragment.TunnelDetailFragment.updateStats (TunnelDetailFragment.java:108)
at com.wireguard.android.fragment.TunnelDetailFragment.access$updateStats (TunnelDetailFragment.java:27)
at com.wireguard.android.fragment.TunnelDetailFragment$onResume$1.run (TunnelDetailFragment.java:74)
at java.util.TimerThread.mainLoop (TimerThread.java:562)
at java.util.TimerThread.run (TimerThread.java:512)

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-04-15 01:57:55 -06:00
Harsh Shandilya 58b14cc650 ui: animate fab position in tunnel deletion flow
When tunnel deletion is triggered we don't bother with animation theatrics
because the resulting Snackbar needs this fab to be its anchor, which it can't
do if its outside the screen or busy animating.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-04-08 19:43:25 +05:30
Harsh Shandilya 3fa8e09545 tunnel: disable BuildConfig generation
We don't (and shouldn't) use BuildConfig values, but the class was
polluting our public API regardless which is undesirable.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-04-08 17:05:31 +05:30
Jason A. Donenfeld 9d76b354f0 version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-04-08 00:02:37 -06:00
Harsh Shandilya 1856a50c56 strings: sync translations
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-04-08 03:37:01 +05:30
Harsh Shandilya ba0f3ece04 ui: tweak FABs to use the correct type
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-04-08 03:34:07 +05:30
Harsh Shandilya e8ad75d924 ui: codestyle nit
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-04-07 14:19:54 +05:30
Jason A. Donenfeld b858284b1e KernelModuleDisablerPreference: do not make synchronous calls to getBackend
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-04-07 02:28:34 -06:00
Jason A. Donenfeld 3c6e06f8d5 ui: set proper content description for applications
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-04-06 19:25:05 -06:00
Jason A. Donenfeld 0d33a00e72 version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-04-06 19:09:25 -06:00
Jason A. Donenfeld 830d0992a7 ui: show excluded/included apps in details view
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-04-06 19:08:57 -06:00
Jason A. Donenfeld e4192ea172 ui: align listen port and mtu in detail editor
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-04-06 18:43:41 -06:00
Jason A. Donenfeld 4bbb1a0fcd ui: add suffix to persistent keepalive in editor
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-04-06 18:24:08 -06:00
Jason A. Donenfeld 77b5937fbb ui: add missing fields to detail view
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-04-06 18:09:03 -06:00
Jason A. Donenfeld 3144d36056 TunnelListFragment: onCreateActionMode is called before adapter is alive
Long press a tunnel item. SIGKILL the app. Reenter it. Boom:

kotlin.KotlinNullPointerException:
  at com.wireguard.android.fragment.TunnelListFragment$ActionModeListener.onCreateActionMode (TunnelListFragment.java:347)
  at androidx.appcompat.app.AppCompatDelegateImpl$ActionModeCallbackWrapperV9.onCreateActionMode (AppCompatDelegateImpl.java:2442)
  at androidx.appcompat.app.WindowDecorActionBar$ActionModeImpl.dispatchOnCreate (WindowDecorActionBar.java:1062)
  at androidx.appcompat.app.WindowDecorActionBar.startActionMode (WindowDecorActionBar.java:530)
  at androidx.appcompat.app.AppCompatDelegateImpl.startSupportActionMode (AppCompatDelegateImpl.java:1055)
  at androidx.appcompat.app.AppCompatActivity.startSupportActionMode (AppCompatActivity.java:316)
  at com.wireguard.android.fragment.TunnelListFragment$ActionModeListener.setItemChecked (TunnelListFragment.java:371)
  at com.wireguard.android.fragment.TunnelListFragment.onActivityCreated (TunnelListFragment.java:174)
  at androidx.fragment.app.Fragment.performActivityCreated (Fragment.java:2717)
  at androidx.fragment.app.FragmentStateManager.activityCreated (FragmentStateManager.java:346)
  at androidx.fragment.app.FragmentManager.moveToState (FragmentManager.java:1188)
  at androidx.fragment.app.FragmentManager.moveToState (FragmentManager.java:161)
  at androidx.fragment.app.FragmentManager.moveToState (FragmentManager.java:1356)
  at androidx.fragment.app.FragmentManager.moveToState (FragmentManager.java:5)
  at androidx.fragment.app.FragmentManager.moveFragmentToExpectedState (FragmentManager.java:1434)
  at androidx.fragment.app.FragmentManager.moveFragmentToExpectedState (FragmentManager.java:5)
  at androidx.fragment.app.FragmentManager.moveToState (FragmentManager.java:1497)
  at androidx.fragment.app.FragmentManager.moveToState (FragmentManager.java:389)
  at androidx.fragment.app.FragmentManager.dispatchStateChange (FragmentManager.java:2625)
  at androidx.fragment.app.FragmentManager.dispatchStateChange (FragmentManager.java:677)
  at androidx.fragment.app.FragmentManager.dispatchActivityCreated (FragmentManager.java:2577)
  at androidx.fragment.app.FragmentManager.dispatchActivityCreated (FragmentManager.java:9)
  at androidx.fragment.app.FragmentController.dispatchActivityCreated (FragmentController.java:247)
  at androidx.fragment.app.FragmentActivity.onStart (FragmentActivity.java:541)
  at androidx.appcompat.app.AppCompatActivity.onStart (AppCompatActivity.java:201)
  at android.app.Instrumentation.callActivityOnStart (Instrumentation.java:1440)
  at android.app.Activity.performStart (Activity.java:8109)
  at android.app.ActivityThread.handleStartActivity (ActivityThread.java:3806)
  at android.app.servertransaction.TransactionExecutor.performLifecycleSequence (TransactionExecutor.java:235)
  at android.app.servertransaction.TransactionExecutor.cycleToPath (TransactionExecutor.java:215)
  at android.app.servertransaction.TransactionExecutor.executeLifecycleState (TransactionExecutor.java:187)
  at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:105)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2386)
  at android.os.Handler.dispatchMessage (Handler.java:107)
  at android.os.Looper.loop (Looper.java:213)
  at android.app.ActivityThread.main (ActivityThread.java:8178)
  at java.lang.reflect.Method.invoke (Method.java)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:513)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1101)

This commit avoids the crash. But it's not clear to me that this is
really the right solution. However, in testing it appears to work.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-04-06 15:56:07 -06:00
Jason A. Donenfeld 521bbb4b4c AppListDialogFragment: refine singular grammar
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-04-06 19:56:53 +05:30
Jason A. Donenfeld 0a55e10b94 AppListDialogFragment: remove colons from tabs
Harsh's club became ill upon seeing them.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-04-06 19:56:53 +05:30
Harsh Shandilya d6e5fd9301 ui: tweak cards to make them nicer on the eyes
Surprisingly-requested-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-04-06 19:56:53 +05:30
Harsh Shandilya 2c625f56fd ui: misc cleanups to AppListDialogFragment
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-04-06 19:56:46 +05:30
Jason A. Donenfeld 7db0fa915e AppListDialogFragment: support both inclusion and exclusion
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-04-06 02:40:49 -06:00
Jason A. Donenfeld e424765a61 tunnel: support IncludedApplications as whitelist
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-04-05 20:04:51 -06:00
Harsh Shandilya 1ca4dbf1a2 tunnel: hold peers in an ArrayList
A set will cause identical peers to be dropped during save

Reported-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-04-06 01:22:44 +05:30
Harsh Shandilya 065893e31d MultiselectableRelativeLayout: use JvmOverloads constructor
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-04-06 00:39:22 +05:30
Harsh Shandilya ef70aa88e1 ui: fix scrolling in detail view
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-04-06 00:17:14 +05:30
Harsh Shandilya 6a11a199ca strings: sync translations
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-04-04 16:19:21 +05:30
Jason A. Donenfeld 7b5ceac9f7 version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-04-03 19:07:33 -06:00
Jason A. Donenfeld 9fe0019ec1 tunnel: libwg-go: use deterministic verdef name
From the ld.gold source:

  const char* name = parameters->options().soname();
  if (name == NULL)
    name = parameters->options().output_file_name();

That means by default it uses `-o {output}` as the verdef aux name,
which is random every time due to Go's build system. By passing in
`--soname={somethingexplicit}` we can instead have a deterministic
verdef.

This commit makes wireguard-android reproducible.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-04-03 19:07:33 -06:00
Jason A. Donenfeld 84654a0302 gradle: upgrade to 6.3
It looks like F-Droid finally updated.

This reverts commit cd43444d1f.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-04-03 19:07:33 -06:00
Jason A. Donenfeld cd43444d1f gradle: downgrade to 6.2.1 to deal with f-droid organizational mismanagement
The fdroidserver repo hardcodes hashes of all gradle versions that are
allowed to be used. This is currently up to date, having 6.3. However,
the f-droid build server is not up to date, because it is controlled by
the founder of f-droid, who is generally unavailable and does not update
it. Meanwhile other members of the project would like to stand up their
own build server instance, but this seems potentially arduous and
there's still the question of the signing key. At least that's the story
I was able to glean from asking around.

So, in order to work around this organizational brokeness, we just
downgrade to 6.2.1.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-04-01 23:43:24 -06:00
Jason A. Donenfeld b7028896c7 ObservableTunnel: do not cache key
Reported-by: Reza Island's <rezza.aji.ras@gmail.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-04-01 22:05:24 -06:00
Jason A. Donenfeld c1e86acb3c tunnel: libwg-go: remove -x option from flock
It's already the default and the macOS port of flock doesn't support it.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-04-01 22:05:24 -06:00
Harsh Shandilya 7d31bd2be9 build: update fragment to 1.2.4
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-04-01 22:05:24 -06:00
Jason A. Donenfeld 2e573a66a4 build: update agp to 3.6.2
Harsh likes to be first in line.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-04-01 22:05:24 -06:00
Harsh Shandilya 8d128cf2e9 ui: disable LongLogTag lint
We know what we're doing

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-31 03:48:00 +05:30
Jason A. Donenfeld d5ffa08480 TunnelEditorFragment: don't show bioauth if already visible
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-30 14:53:25 -06:00
Jason A. Donenfeld 43ce69bef4 version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-30 14:14:54 -06:00
Harsh Shandilya 44a0f53e58 strings: sync translations
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-30 14:08:24 -06:00
Jason A. Donenfeld d74b988f75 global: cleanup code style
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-30 13:57:43 -06:00
Harsh Shandilya 10e910186e ui: update proguard rules to keep crash logs readable
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-30 13:49:41 -06:00
Jason A. Donenfeld 017f420d42 LogViewerActivity: don't crash if pipe closes
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-30 03:25:47 -06:00
Jason A. Donenfeld bc186fe6ad TunnelDetail: set singleLine=true for API <=23
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-30 03:23:32 -06:00
Jason A. Donenfeld 09b40cdec7 BiometricAuthenticator: rework logic and bugs
Otherwise there's a frameworks bug that causes the fragment's activity
to become null.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-30 03:23:32 -06:00
Harsh Shandilya d2721f2d7d BiometricAuthenticator: implement biometric authentication for sensitive operations
When biometric hardware is available, it will be used to authenticate
the user before private keys are shown on screen or when zip exports
are executed.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-30 03:23:32 -06:00
Harsh Shandilya 3095e19e13 ObservableTunnel: Don't cache configAsync
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-30 03:23:32 -06:00
Jason A. Donenfeld c547d033c3 ui: replace generate icon with 'sync' instead of 'toys'
I dislike this change, but Harsh thinks the toys icon is utterly insane
and maybe he's right.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-30 03:23:32 -06:00
Jason A. Donenfeld 4d4764eefb BindingAdapters: use sleeker lambda
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-30 03:23:32 -06:00
Jason A. Donenfeld d44a83faaa TunnelEditorFragment: add hooks for biometric auth
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-30 03:23:32 -06:00
Vincenzo Reale 2337fe37be strings: update Italian translation
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-29 17:26:14 -06:00
Jason A. Donenfeld c5b71cb484 README: mention translations
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-29 17:16:09 -06:00
Jason A. Donenfeld 480c95d4d6 ui: remove unused stream support
The tunnel/ module still uses it and exposes it as an "api", but nothing
inside of ui/ should be using it now.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-29 17:00:31 -06:00
Harsh Shandilya 8a45e965eb strings: Sync German translations
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-29 14:10:39 +05:30
Jason A. Donenfeld c9717693d0 tunnel: libwg-go: check sha256 of downloaded tarball
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-29 02:36:29 -06:00
Jason A. Donenfeld 0fa3fe3d43 tunnel: libwg-go: stick go tarball in gradle cache
This way we don't have to build over and over.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-29 02:28:41 -06:00
Jason A. Donenfeld ed090f7ecb strings: fix positional specifier in russian translation
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-29 01:52:01 -06:00
Jason A. Donenfeld f916f96761 tunnel: libwg-go: prevent parallel downloads
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-29 01:31:39 -06:00
Jason A. Donenfeld 79e766c4e1 tunnel: fix package name being passed through to cmake
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-29 01:18:46 -06:00
Harsh Shandilya 183273dcf5 AddTunnelsSheet: Make behaviour nullable
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-29 11:04:59 +05:30
Harsh Shandilya b3bb7c694b build: Improve R8 rules and enable aggressive optimization modes
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-29 10:52:54 +05:30
Jason A. Donenfeld 456a74db05 global: hardcode tags so that minification doesn't ruin the log
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-28 23:21:12 -06:00
Jason A. Donenfeld fde724a658 version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-28 23:07:50 -06:00
Jason A. Donenfeld 574ee5d0bb LogViewerActivity: only scroll every quarter for the first 2.5 seconds of dumping
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-28 23:07:50 -06:00
Harsh Shandilya 03a838ba2d ui: Remove unnecessary non-null assertion in TAG fields
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-28 23:07:50 -06:00
Harsh Shandilya b00aacbc41 Fix tunnel editor theming
Also set textInputStyle in the base theme to avoid setting styles to all elements

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-28 22:38:04 -06:00
Jason A. Donenfeld 532c33a13b MonkeyedTextInputEditText: make more robust
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-28 22:38:04 -06:00
Jason A. Donenfeld 6a7396bc1d ui: use kotlin class instead of java class for tag
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-28 16:26:22 -06:00
Jason A. Donenfeld 870b2bf36d ObservableTunnel: do not cache stats
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-28 16:26:22 -06:00
Jason A. Donenfeld 07b69be7bf TunnelEditor: fix up allowedips margins
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-28 16:26:22 -06:00
Jason A. Donenfeld b41640837c TunnelEditor: get rid of weird gravity on add peer button
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-28 16:26:22 -06:00
Jason A. Donenfeld bee6ebe3b4 TunnelEditor: move generate button to inside box
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-28 16:26:22 -06:00
Jason A. Donenfeld 5989298d3f TunnelEditor: subdue section font
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-28 16:26:22 -06:00
Jason A. Donenfeld 0235f19543 TunnelEditor: abstract out section font
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-28 16:26:22 -06:00
Jason A. Donenfeld cd6c2f68ca TunnelEditor: properly align mtu and listen port
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-28 16:26:22 -06:00
Jason A. Donenfeld 75252cf9d5 TunnelEditor: move hint to label and add discouraged optional
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-28 16:26:22 -06:00
Jason A. Donenfeld 1da714852f TunnelEditor: clean up xml
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-28 16:26:22 -06:00
Jason A. Donenfeld fe6b788f6b MonkeyedTextInputEditText: introduce a new horror
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-28 16:26:22 -06:00
Harsh Shandilya fb3fec299f TunnelEditor: replace tunnel detail view with ConstraintLayout implementation
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-28 15:22:11 -06:00
Harsh Shandilya d2f435b265 ClipboardUtils: Update to handle TextInputEditText
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-28 15:22:06 -06:00
Harsh Shandilya 3a163acd6d gradle: Remove useless comment
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-28 19:50:34 +05:30
Harsh Shandilya df4bf9b688 Disable screen capture in tunnel editor
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-28 19:49:54 +05:30
Harsh Shandilya 0f67a2f194 Upgrade streamsupport dependency
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-28 19:21:53 +05:30
Jason A. Donenfeld b75946af46 TunnelComparator: naturally sort tunnel list
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-28 01:42:06 -06:00
Harsh Shandilya b9b188693c strings: Sync from Crowdin
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-28 02:55:21 +05:30
Harsh Shandilya 9fe008d407 ObservableTunnel: Don't recurse in getConfig
The correct way to retrieve the value inside a getter/setter is to use `field` to ensure
you don't invoke the getter while inside the getter and trigger a stack overflow

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-28 02:35:01 +05:30
Jason A. Donenfeld e905c355f9 README: mention docs location
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-27 14:26:08 -06:00
Alexey 12821fb70d strings: update Russian translate
Signed-off-by: Alexey <zasranecc@bk.ru>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-27 13:31:20 -06:00
Jason A. Donenfeld 2aaa316280 gradle: bump threetenabp to 1.2.3
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-27 13:20:51 -06:00
Jason A. Donenfeld 918d9b8b1f databinding: simplify and address warnings
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-27 15:38:04 +05:30
Harsh Shandilya 536a6f3f83 ui: Replace ErrorMessages getter with indexing operator
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-27 15:38:04 +05:30
Harsh Shandilya b9fd3d37f2 Convert ErrorMessages to Kotlin
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-27 15:38:04 +05:30
Harsh Shandilya e0b87c3ff2 Convert AsyncWorker to Kotlin
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-27 03:09:24 -06:00
Jason A. Donenfeld 48a9fd46a6 databinding: rewrite in kotlin
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-27 03:08:47 -06:00
Jason A. Donenfeld 8669c01eaa util: begin conversion to kotlin
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-27 03:08:47 -06:00
Jason A. Donenfeld 37949ba1ec TunnelManager: convert to kotlin
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-26 23:21:54 -06:00
Harsh Shandilya b2bbaf050c util: Start converting to Kotlin
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-26 22:33:01 -06:00
Jason A. Donenfeld 4d6837ea53 ObservableTunnel: port to kotlin
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-26 22:30:10 -06:00
Jason A. Donenfeld c8ac970d11 LogViewerActivity: merge lines that don't match regex
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-26 16:59:54 -06:00
Jason A. Donenfeld a3a429bc41 LogViewerActivity: re-add error case to log export
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-26 15:58:02 -06:00
Alexey 0726b1b4d9 strings: update Russian translate
Signed-off-by: Alexey <zasranecc@bk.ru>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-26 15:43:41 -06:00
Jason A. Donenfeld defc4f45ff LogViewerActivity: constify request
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-26 14:56:13 -06:00
Jason A. Donenfeld a984127e28 LogViewerActivity: set a separate title
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-26 14:59:31 +05:30
Jason A. Donenfeld 85dd303c88 ui: root: rewrite in kotlin
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-26 01:55:44 -06:00
Jason A. Donenfeld 2958144fd0 ui: cleanup various pieces of kotlin
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-26 00:51:36 -06:00
Jason A. Donenfeld ade8f18a95 xml: cleanup
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-26 00:49:01 -06:00
Jason A. Donenfeld 46e2e29ead preferences: add key to all items to squelch warnings
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-26 00:49:01 -06:00
Harsh Shandilya 63a395125a Introduce realtime log viewer
This contains a share button and a save button, the former using a
custom content provider.

Co-authored-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-26 00:49:01 -06:00
Alexey 6f973afa36 strings: update Russian translate
Signed-off-by: Alexey <zasranecc@bk.ru>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-25 12:43:54 -06:00
Harsh Shandilya 1ad0ef3f61 LogExporterPreference: Don't ask for storage permissions on Android 10 and above
We use the proper MediaStore implementation on Android 10 which makes it unnecessary.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-25 21:02:02 +05:30
Eiji Tanioka 90bf46e8d3 strings: Explicit indexing for 'import_partial_success'
When translate it to Japanese, values are exchanged.
For example, '1 of 10' is '10 個中の 1'.

So this string should be explicit indexed.

Signed-off-by: Eiji Tanioka <tanioka404@gmail.com>
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-25 20:23:45 +05:30
Harsh Shandilya c1c285db86 Upgrade to Gradle 6.3
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-25 02:05:12 +05:30
Jason A. Donenfeld f1b541a1eb ui: squelch warnings
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-24 14:17:18 -06:00
Jason A. Donenfeld 585257c995 TunnelManager: disallow remote apps for L
I don't trust old Android versions to have gotten this right.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-24 14:17:15 -06:00
Harsh Shandilya 93f80cdc50 Resolve manifest warnings
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-24 11:30:28 +05:30
Jason A. Donenfeld a832193010 TunnelManager: save settings before restart
Otherwise these get lost and then the restored state is confusing.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-23 18:14:23 -06:00
Harsh Shandilya 383659fb8a Upgrade to Kotlin 1.3.71
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-23 22:50:04 +05:30
Jason A. Donenfeld 4725e55090 libwg-go: update go modules
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-22 14:08:20 -06:00
Jason A. Donenfeld 07c85ee6f5 version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-22 13:09:09 -06:00
Jason A. Donenfeld c02dd9e040 Preferences: hide advanced settings
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-22 01:50:58 -06:00
Jason A. Donenfeld 7dae94976d SettingsActivity: remove from parent instead of fixed screen
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-22 01:23:23 -06:00
Jason A. Donenfeld 38c360cb74 libwg-go: bump go version
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-22 01:07:20 -06:00
Jason A. Donenfeld edba640641 TunnelManager: enable Tasker support
Also fix up wording for the permission prompt that Tasker will show when
initially setting this up.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-22 00:51:37 -06:00
Jason A. Donenfeld cf25ae4448 model: begin conversion
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-22 00:19:09 -06:00
Eiji Tanioka e86182af56 strings: Update Japanese translation.
Signed-off-by: Eiji Tanioka <tanioka404@gmail.com>
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-21 19:18:36 +05:30
Jason A. Donenfeld 902a1ce46e viewmodel: port to kotlin
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-21 03:06:56 -06:00
Harsh Shandilya 55849cad65 Replace PermissionRequestCallback with direct methods
These are much cleaner in Kotlin code.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-20 22:22:56 -06:00
Harsh Shandilya edb76af820 build: Load keystore file from rootProject
Since the signing config is also stored in the project root it makes sense to have storeFile
path be relative to it.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-20 22:22:56 -06:00
Harsh Shandilya 04d0b819f6 Convert activity package to Kotlin
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-20 22:22:56 -06:00
Jason A. Donenfeld 85aa5fbd46 AddTunnels: rearrange and relabel
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-20 02:56:10 -06:00
Jason A. Donenfeld 1054e54c89 widget: rewrite in kotlin
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-20 02:46:01 -06:00
Jason A. Donenfeld 2fe5b92035 EdgeToEdge: move into widget
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-20 02:28:49 -06:00
Fiqri Ardyansyah 3a5a161c03 strings: Update Indonesian translation
Signed-off-by: Fiqri Ardyansyah <fiqri15072019@gmail.com>
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-19 18:56:05 -06:00
Jason A. Donenfeld 8451321a79 preferences: rewrite in kotlin
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-19 18:55:45 -06:00
Jason A. Donenfeld 90050a0008 TunnelListFragment: cleanup list type
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-19 17:52:51 -06:00
Jason A. Donenfeld 87c9efce4a TunnelListFragment: catch all parsing exceptions
Otherwise we crash if weird things happen.

Reported-by: Luis Ressel <aranea@aixah.de>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-19 13:05:53 -06:00
Jason A. Donenfeld 240e049e46 InetEndpoint: return proper parser exception
Wrapping this in something foreign doesn't make sense.

Reported-by: Luis Ressel <aranea@aixah.de>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-19 13:04:31 -06:00
Harsh Shandilya 0899b49bb3 Use more Kotlin-esque code where applicable
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-19 14:45:07 +05:30
Harsh Shandilya fc0660ca8d ui: Convert fragment package to Kotlin
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-19 09:24:48 +05:30
Harsh Shandilya b2ed5dbbc8 codestyle: Require atleast 10 references before using star imports
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-19 09:24:48 +05:30
Harsh Shandilya 94c864503e ui: Convert configStore package to Kotlin
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-19 09:24:47 +05:30
Eiji Tanioka c387c6aebf strings: Update Japanese Translation
Signed-off-by: Eiji Tanioka <tanioka404@gmail.com>
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-19 09:16:16 +05:30
Harsh Shandilya 55c9d39c13 strings: Remove now defunct translations
The original strings are removed.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-18 15:18:02 +05:30
Jason A. Donenfeld 6a3b143876 preference: restart application immediately
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-17 23:51:41 -06:00
Shashank Baghel 5f29abfa0d strings: update Hindi translation
Signed-off-by: Shashank Baghel <theradcolor@gmail.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-17 21:46:13 -06:00
Fiqri Ardyansyah ea3364ac12 strings: add Indonesian translations
Signed-off-by: Fiqri Ardyansyah <fiqri15072019@gmail.com>
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-17 21:45:16 -06:00
Harsh Shandilya 2b31eac1af publish.gradle: Use non-deprecated API to prevent eager configuration of tasks
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-14 10:44:52 +05:30
Harsh Shandilya 093139bc91 tunnel: Add an initial set of unit tests
Includes a control set of broken configuration files that we attempt to parse and
verify that the parser fails in a predictable and consistent manner.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-14 10:32:12 +05:30
Harsh Shandilya 6c8a4a6a28 tunnel: Remove MISSING_VALUE from BadConfigException reasons
This is covered under SYNTAX_ERROR which feels like a reasonable choice,
so get rid of this unused field and associated resource string.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-14 10:25:57 +05:30
Jason A. Donenfeld f5d2fd6190 config: show missing section error correctly
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-13 13:20:34 -06:00
LilligantMatsuri 4d77bd8f25 strings: update Simplified Chinese translation
Signed-off-by: LilligantMatsuri <srb12345@vip.qq.com>
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-12 17:26:36 +05:30
Eiji Tanioka 1068adbee3 strings: update Japanese translation
Signed-off-by: Eiji Tanioka <tanioka404@gmail.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-12 01:26:56 -06:00
Jason A. Donenfeld 86fc518585 tunnel: replace CompletableFuture with GhettoCompletableFuture
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-12 01:14:13 -06:00
Jason A. Donenfeld 78377a5c67 tunnel: we return Optional types so mark retrostreams as api
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-12 00:23:03 -06:00
Jason A. Donenfeld 56f2dcc073 tunnel: add javadoc support
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-11 00:29:18 -06:00
Alexey 48739b4141 strings: update Russian translate
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-11 00:29:18 -06:00
Jason A. Donenfeld 704c344213 tunnel: the external API does not expose java9
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-10 11:52:30 -06:00
Jason A. Donenfeld ee263ba68e README: note JCenter addition
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-10 11:49:04 -06:00
Jason A. Donenfeld 692b71af23 tunnel: tools: update to latest go
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-10 22:12:16 +05:30
Jason A. Donenfeld 7e029f1db0 ModuleDownloaderPreference: remove disable_kernel_module after downloading
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-10 22:12:16 +05:30
Jason A. Donenfeld d4875afe31 tunnel: make use of @RestrictTo
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-10 22:12:16 +05:30
Jason A. Donenfeld de0e431d00 build: abstract out groupName
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-10 22:12:12 +05:30
Jason A. Donenfeld 6b304391b5 global: java access control has important semantic meaning
It's not right to blindly follow all of AndroidStudio's suggestions,
especially for things in tunnel/ which comprise useful API.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-10 08:44:38 -06:00
Harsh Shandilya 8f85e4c88f tunnel: Codestyle cleanups
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-10 13:20:16 +05:30
Harsh Shandilya a3b9c3b884 ui: Codestyle cleanups
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-10 13:08:28 +05:30
Harsh Shandilya 021e16959f Upgrade to Gradle 6.2.2
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-10 12:45:06 +05:30
Harsh Shandilya 37adab76e1 BaseFragment: Always anchor Snackbars to FAB
This makes tunnel list fragment correctly render them above the FAB.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-10 12:32:23 +05:30
Jason A. Donenfeld 5d342ee1ab tunnel: upload aar to bintray
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-10 00:29:38 -06:00
Jason A. Donenfeld 697d131397 strings: remove stale translations
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-09 22:32:56 -06:00
Jason A. Donenfeld 89d9e30025 build: apply version to both modules
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-09 21:54:27 -06:00
Jason A. Donenfeld dfde86df76 Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-09 17:31:52 -06:00
Jason A. Donenfeld d55fb25a40 KernelModuleDisablerPreference: turn off tunnels before switching backend
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-09 16:18:55 -06:00
Jason A. Donenfeld 492fcce053 KernelModuleDisabler: allow disabling the kernel module backend
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-09 15:21:34 -06:00
Jason A. Donenfeld d61f17dbd3 Preferences: give dual state summary for restore on boot
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-09 14:54:20 -06:00
Jason A. Donenfeld 8996979dc2 Preferences: reorder new checkbox
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-09 14:49:31 -06:00
Jason A. Donenfeld 31ddb242a6 VersionPreference: reverse go and wgquick titles
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-09 14:48:02 -06:00
Jason A. Donenfeld b7b5d96b3b TunnelDetailFragment: avoid integer overflow
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-09 12:38:38 -06:00
Jason A. Donenfeld 2e55e5fd05 global: format code
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-09 12:36:47 -06:00
Jason A. Donenfeld 40ebf8006e global: optimize imports
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-09 12:21:35 -06:00
Jason A. Donenfeld 8e8643122e global: get rid of nonnull gradle hack
Hacking things up via gradle is not right, and package-info.java poses
problems with two modules, so instead we just apply it manually to every
class.

Remember to add this to new classes!

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-09 12:19:15 -06:00
Jason A. Donenfeld c00a0b12e4 Application: simplify static block
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-09 12:16:02 -06:00
Jason A. Donenfeld 0e21520fd1 gradle: use optimized proguard rules
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-09 11:29:17 -06:00
Harsh Shandilya 0db233e5c7 Use dark system bars on API 21
Light system bars didn't come around until API 23.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-09 22:12:14 +05:30
Jason A. Donenfeld b9948085a4 ThemeChangeAwareActivity: recreate activity after changing theme
API 21 had issues without this.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-09 10:39:04 -06:00
Jason A. Donenfeld d62526fde6 WgQuickBackend: by default use single-tunnel mode like GoBackend, but add option
Note that this currently doesn't play well with people activating
wg-quick tunnels from outside the app. Those tunnels won't be
deactivated. But presumably that's desired behavior anyway, considering
people are mucking around at the command line.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-09 10:02:00 -06:00
Jason A. Donenfeld 134f9c014e ObservableTunnel: pass right argument to state transition
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-09 09:55:05 -06:00
Jason A. Donenfeld 056cf472d9 ModuleLoader: move to right project
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-09 09:07:48 -06:00
Jason A. Donenfeld 0c161cc0c2 AsyncWorker: move back to original location
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-09 08:59:37 -06:00
Harsh Shandilya 7894894610 Use AndroidX Nullable annotation everywhere
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-09 19:24:27 +05:30
Harsh Shandilya 7d48bef70a Rename app module to ui
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-09 19:24:27 +05:30
Harsh Shandilya 6bc3e257f8 Enable nonnull generation for tunnel module
Also cleanup nonnull.gradle while we're at it

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-09 19:24:26 +05:30
Harsh Shandilya adc613d801 Migrate tunnel related classes to tunnel/ Gradle module
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-09 19:24:26 +05:30
Jason A. Donenfeld fd573f6c1c ToolsInstaller: restrict to only main app usage
We don't want lots of different packages fighting over who gets to
install the tools.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-09 05:07:27 -06:00
Jason A. Donenfeld 1235e966d2 ToolsInstaller: remove versioning
Not ideal, but allows us to get rid of the BuildConfig requirement.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-09 05:07:02 -06:00
Jason A. Donenfeld e6a2f049ea RootShell: remove need for BuildConfig
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-09 04:48:58 -06:00
Jason A. Donenfeld d9e9dd04af Tunnel: move state change into interface
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-09 04:46:17 -06:00
Harsh Shandilya 3c2fa15dc2 Fix tablet mode crashes and UI inconsistencies
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-09 10:50:36 +05:30
Harsh Shandilya e8c9c20570 MainActivity: Dispatch insets to all fragments
Fixes tunnel list fragment rendering behind statusbar when other fragments are showing

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-09 10:32:48 +05:30
Harsh Shandilya 0db2578ca0 Switch to CoordinatorLayout for activity container
Snackbars use it to infer the right margins

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-09 10:32:03 +05:30
Harsh Shandilya e71d6157f1 Add coordinatorlayout dependency and sort
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-09 10:20:14 +05:30
Harsh Shandilya 7ca2a0df18 global: Use requireContext rather than getContext in fragments
requireContext provides helpful error messages when it's null as opposed to getContext
which simply throws a NullPointerException.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-09 10:12:50 +05:30
Jason A. Donenfeld 7a4af834c2 Backend: do not use singletons
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-08 20:23:25 -06:00
Jason A. Donenfeld 314a0d124d GoBackend: setConfigureIntent does nothing
It's only used from the ManageDialog in VpnDialogs, which in turn is
only instantiated in the legacy VPN path.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-08 19:52:57 -06:00
Jason A. Donenfeld 6f1e86e8a7 ToolsInstaller: do not use R
This is horible! But ToolsInstaller uses lots of other error strings
nakedly, as does ModuleLoader. These both need to be fixed up the proper
way (like the last two commits). This commit here is just to make the
initial porting a bit easier.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-09 01:42:38 +08:00
Jason A. Donenfeld 840c7ea560 RootShell: properly use errormessages
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-09 01:36:01 +08:00
Jason A. Donenfeld 1839730663 ModuleDownloaderPreference: properly use errormessages
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-09 01:28:41 +08:00
Jason A. Donenfeld afd75cc4cf ErrorMessages: do not use R from backend
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-09 00:58:32 +08:00
Jason A. Donenfeld 453a1aaa65 ErrorMessages: do not traverse down into remote exceptions
Otherwise we miss the actual error message.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-09 00:19:56 +08:00
Jason A. Donenfeld 4905185e61 backend: do not depend on anything except config
This is likely broken but should make for a good starting point.

It also should hopefully handle stopping tunnels before starting new
ones, in the case of the GoBackend. Again, untested.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-03-09 00:19:42 +08:00
Harsh Shandilya 0990430513 Upgrade AGP and Kotlin
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-08 14:05:45 +08:00
Shashank Baghel 7df13a044f Add Hindi translation
Signed-off-by: Shashank Baghel <theradcolor@gmail.com>
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-08 14:05:36 +08:00
Harsh Shandilya 6135a1f60a MainActivity: Remove unused imports
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-02-28 13:25:28 +05:30
Harsh Shandilya 5e94adc73a ModuleLoader: Staticize isModuleLoaded
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-02-28 13:16:31 +05:30
Harsh Shandilya 44fc0228a9 Upgrade to build tools 29.0.3
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-02-28 12:28:02 +05:30
Harsh Shandilya 4d2bfe3ef3 Resolve some lint and build warnings
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-02-26 20:26:49 +05:30
LilligantMatsuri 7f37ff032f Add Simplified Chinese translation
Signed-off-by: LilligantMatsuri <srb12345@vip.qq.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-02-25 22:04:01 -06:00
Eiji Tanioka 30d508464f remove <item quantity=one> tag due to no plural form in Japanese.
Signed-off-by: Eiji Tanioka <tanioka404@gmail.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-02-25 22:00:15 -06:00
Harsh Shandilya 75b0fed00d ThemeChangeAwareActivity: Remove drawable cache buster
Shouldn't be needed anymore.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-02-25 17:14:52 +05:30
Harsh Shandilya 927cc1fcf5 Make exclusions dialog fit more items in viewport
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-02-25 14:23:28 +05:30
Harsh Shandilya b3090e277a MainActivity: Fix backstack bug exposed by fragment 1.2.2
We've been relying on implicit backstack changes to handle removing the detail fragment for a while which is now gone so let's do this properly like we should

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-02-25 14:23:28 +05:30
Harsh Shandilya 0b45151a3d Resolve deprecation warnings
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-02-25 09:53:01 +05:30
Harsh Shandilya eb5bfa9b5d Cleanup inset dispatch code
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-02-25 09:53:00 +05:30
Harsh Shandilya 4267e94dcd Replace FrameLayouts with recommended FragmentContainerView
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-02-25 08:57:29 +05:30
Harsh Shandilya fac9e7612f Add fragment dependency
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-02-25 08:57:28 +05:30
Harsh Shandilya 01e8e535f4 Ensure insets are dispatched to all fragments
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-02-25 08:57:28 +05:30
Harsh Shandilya e5e2e7571f Setup EdgeToEdge
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-02-25 08:57:27 +05:30
Harsh Shandilya c889a8c8de Add EdgeToEdge and coreKtx dependency
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-02-25 08:57:26 +05:30
Harsh Shandilya cbf2ea7b48 Target JVM 1.8 from Kotlin as well
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-02-25 08:57:26 +05:30
Harsh Shandilya 8078347880 Upgrade AGP and Gradle
If anybody has a problem with missing or mismatched NDK, run this command to install the right version

$ANDROID_SDK_ROOT/tools/bin/sdkmanager 'ndk;20.0.5594570'

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-02-25 08:29:53 +05:30
Harsh Shandilya dd8a802bec Resolve format string warnings
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-02-23 18:55:09 +05:30
Harsh Shandilya 6f6602ddd1 AppListDialogFragment: Revamp toggle logic
Rather than always toggle all elements, elect to unselect all if any are selected. This allows
returning to a clean state in at most two clicks.

Suggested-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-02-23 15:07:39 +05:30
Harsh Shandilya 33e69db436 AppListDialogFragment: Code cleanup
- Using the require_() methods provides helpful error messages when things are null
compared to the get_() methods which throw NPEs.
- Ensure currentlyExcludedApps is empty but never null
- Rename inner variable to silence name shadowing lint
- Make setExclusionsAndDismiss private

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-02-23 15:07:39 +05:30
Eiji Tanioka 13cbec28d6 Japanese translation: change "Deselect All" to "Toggle All"
Fixes: 1eb4ce7 ("AppListDialogFragment: change "Deselect All" to "Toggle All"")
Signed-off-by: Eiji Tanioka <tanioka404@gmail.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-02-23 10:11:14 +01:00
Sébastien LEBEAU 826083adf6 AppListDialogFragment: change "Deselect All" to "Toggle All"
Change functionality in excluded apps dialog for better user experience
when user wants only one or few apps to use WireGuard.

Signed-off-by: Sébastien LEBEAU <sebcbi1@gmail.com>
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-02-23 10:11:12 +01:00
Harsh Shandilya a62bd28e1f SharedLibraryLoader: Fix leaked Closeable warning
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-02-16 15:07:21 +05:30
Harsh Shandilya da1188c6ee Record StrictMode failures to logcat
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-02-16 15:07:20 +05:30
Eiji Tanioka e22cefbfe3 Add japanese translation.
Signed-off-by: Eiji Tanioka <tanioka404@gmail.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-02-15 00:06:18 -06:00
Harsh Shandilya 02ea696070 Port tunnel creation UI from Viscerion
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-02-14 15:27:17 +05:30
Harsh Shandilya d25702d99d Implement custom theming to match Google's AOSP design
Closes: #4
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-02-12 15:23:53 +01:00
Jason A. Donenfeld c554413327 Attribute: remove need for android TextUtils
If this is to be JRE-only, then it doesn't make sense to rely on the
android class, especially since this is so trivial to inline.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-02-10 17:04:34 +01:00
Jason A. Donenfeld f8c5f238ea InetAddresses: don't have global android import
This allows a proper fallback on normal JRE.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-02-10 16:55:34 +01:00
Alexey 66b46c8618 Update Russian translation
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-02-09 11:27:30 +01:00
Jason A. Donenfeld 04689d37b7 version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-02-06 22:01:03 +01:00
Jason A. Donenfeld e041cacf4b wg: bump to latest snapshot
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-02-06 22:01:03 +01:00
Alexey f54fc92b14 Add Russian translation
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-02-06 22:01:03 +01:00
Jason A. Donenfeld 6e7b6bcc35 wg-go: bump go requirement
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-02-03 17:21:34 +01:00
Jason A. Donenfeld e70d5be535 wg: remove mnl dependency and bump dep
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-02-03 17:09:45 +01:00
Jason A. Donenfeld 2ce51c8c2e version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-01-24 15:36:50 +01:00
Jason A. Donenfeld c621ec0c50 GoBackend: restrict APIs to proper version
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-01-24 15:36:27 +01:00
Harsh Shandilya 2ed2a1431d Upgrade to Gradle 6.1
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-01-24 09:57:25 +05:30
Harsh Shandilya 3a425394ca GoBackend: Ensure we're unmetered on API 29 as well
VPN apps targetting Android 10 are treated as metered by default.

Source: https://developer.android.com/reference/android/net/VpnService.Builder.html#setMetered(boolean)

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-01-24 09:51:48 +05:30
Jason A. Donenfeld d98ba463ad version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-01-23 16:12:26 +01:00
Jason A. Donenfeld c3d97acb31 Rework timer in tunnel detail
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-01-23 16:12:26 +01:00
Jason A. Donenfeld 8dbd464fa4 Match lowercase asus phones for fab hack
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-01-23 16:10:34 +01:00
Jason A. Donenfeld 63a5bb1bbf manifest: reorder
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-01-23 16:10:34 +01:00
Jason A. Donenfeld 8c03878808 tools: update deps
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-01-23 13:46:29 +01:00
Jason A. Donenfeld d29e50e50b GoBackend: set empty underlying networks
https://lists.zx2c4.com/pipermail/wireguard/2020-January/004859.html
https://issuetracker.google.com/issues/114309459
https://developer.android.com/about/versions/pie/android-9.0-changes-all#network-capabilities-vpn

Apparently we need to call this at least once.

Reported-by: Andrey Kupreychik <foxel@quickfox.ru>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-01-23 13:45:08 +01:00
Revath S Kumar 687bf8b208 Manifest: make wireguard compatible with android TV
As of now wireguard is not listed in Android TV play store
due to the lack of CATEGORY_LEANBACK_LAUNCHER [1].
Even the app is not listed when we sideload into TV device[2].

[1]: https://developer.android.com/reference/android/content/Intent.html#CATEGORY_LEANBACK_LAUNCHER
[2]: https://developer.android.com/training/tv/start/start.html#tv-activity

Signed-off-by: Revath S Kumar <rsk@revathskumar.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-01-22 20:56:49 +01:00
xalloc 10d0807395 Add Italian translation
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-01-22 20:56:06 +01:00
Jason A. Donenfeld 0a89c87190 tools: bump to new wireguard-tools repo
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-12-27 16:49:30 +01:00
Jason A. Donenfeld a7df92a64c Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-12-20 11:31:58 +01:00
Harsh Shandilya 4d3043c041 Introduce TunnelToggleActivity
On Android 10, apps cannot start services when they're in the
background. This means that starting VpnService from within
QuickTileService when the app is not active ends badly. To mitigate this
situation, we introduce a proxy activity of sorts that will handle
starting VpnService for us. The activity is completely transparent and
invisible, and does only four things:

- Toggle the tunnel state
- Request the Tile bound by QuickTileService to refresh its state
- Handle any error that might have been thrown during toggle
- Call finishAffinity() and go away

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2019-12-20 11:26:33 +01:00
Jason A. Donenfeld 8261a18472 Use RequiresApi instead of TargetApi
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-12-20 11:14:38 +01:00
Harsh Shandilya a9f04c0bf4 Update AGP to 3.5.3
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2019-12-15 11:08:00 +05:30
Harsh Shandilya 84334a6bc9 Update Gradle to 6.0.1
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2019-12-15 11:07:59 +05:30
Jason A. Donenfeld 1e5596f977 QuickTileService: require phone be unlocked
Reported-by: Simon <simon@laro.se>
Reported-by: Harsh Shandilya <me@msfjarvis.dev>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-11-27 13:12:12 +01:00
Jason A. Donenfeld b67fa3a38c Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-11-20 12:44:54 +01:00
Jason A. Donenfeld 8b0123042f Implement statistics
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-11-20 12:44:54 +01:00
Jason A. Donenfeld 16890a659e ModuleLoader: sync file before renaming
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-10-22 15:05:22 +02:00
Jason A. Donenfeld d40ac7f89d ToolsInstaller: write to temporary file, fsync, rename
Reported-by: Andre Christanto <christantoandre@gmail.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-10-21 18:56:28 +02:00
Jason A. Donenfeld 2694f48b87 libwg-go: version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-10-18 14:57:12 +02:00
Jason A. Donenfeld 0f91aeb2d3 Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-10-18 13:37:59 +02:00
Jason A. Donenfeld bc0111f895 InetAddresses: cleanup and implement final fallback
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-10-18 13:37:07 +02:00
Jason A. Donenfeld f8a3e9b332 libwg-go: version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-10-18 13:10:08 +02:00
Jason A. Donenfeld db9397fd3e Application: put user agent in log to help debugging
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-10-18 13:06:54 +02:00
Jason A. Donenfeld 20717ff128 Suppress depreciation warnings
We know what we're doing here, and it's not nice.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-10-18 13:06:54 +02:00
Jason A. Donenfeld a532a88585 Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-10-16 14:46:23 +02:00
Jason A. Donenfeld 0b077bd523 tools: bump wg-quick
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-10-16 14:46:10 +02:00
Jason A. Donenfeld e008efcf97 Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-10-16 10:03:47 +02:00
Jason A. Donenfeld 7cf676f9bd Google doesn't want to enable others to support free open source software
Revert "preferences: add donation link"

This reverts commit e5455f579aec48abb30ba68b0248b02d79303126.

The app was removed from the Play Store for violating their payments
policy. Upon filing an appeal, I was told that they do not allow
donations to projects like WireGuard.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-10-16 10:01:01 +02:00
Jason A. Donenfeld b83538d08d Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-10-14 00:24:47 +02:00
Jason A. Donenfeld 3c31c340d8 Download modules after verifying signify signature
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-10-14 00:03:39 +02:00
Jason A. Donenfeld 59620456ee Revert "Fix activity leak on Android Q"
This reverts commit 489518000971914b2608da43e2146690dcc02cb9.

October has arrived.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-10-13 14:10:11 +02:00
Jason A. Donenfeld e42bd29382 Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-10-13 14:10:11 +02:00
Jason A. Donenfeld 18dbc21f96 libwg-go: overwrite socket directory correctly
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-10-13 14:09:40 +02:00
Jason A. Donenfeld 68d871c47c Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-10-13 11:53:17 +02:00
Jason A. Donenfeld a45a219e5f proguard: reenable obfuscation
Android bundles let us keep everything together.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-10-13 11:53:17 +02:00
Jason A. Donenfeld 49788240aa libwg-go: version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-10-13 11:46:41 +02:00
Jason A. Donenfeld 52166500fd ToolsInstaller: extract from apk instead of relying on native extraction
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-10-13 11:46:41 +02:00
Jason A. Donenfeld 3c8fef2655 SharedLibraryLoader: separate out extraction
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-10-13 11:46:41 +02:00
Jason A. Donenfeld 21af2f2f62 libwg-go: overwrite socket directory correctly
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-10-13 11:46:41 +02:00
Jason A. Donenfeld 6d01296e8b SharedLibraryLoader: prioritize ABI ordering
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-10-13 11:46:41 +02:00
Jason A. Donenfeld 749efcde21 SharedLibraryLoader: iterate through all apks for bundles
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-10-13 11:46:41 +02:00
Jason A. Donenfeld 3af2420da9 Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-10-12 18:55:28 +02:00
Nicolas Douma d0d24f4554 tools: prepare for binder usage in wg-quick
Signed-off-by: Nicolas Douma <nicolas@serveur.io>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-10-12 18:55:28 +02:00
Jason A. Donenfeld 96b44c1771 Activity: make dark/night theme follow system on Q
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-10-12 18:55:28 +02:00
Jason A. Donenfeld 4a1d07b364 Application: use preferences from compat libs
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-10-12 18:55:28 +02:00
Jason A. Donenfeld 7fbe5349a2 export: use content resolver on android Q+
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-10-12 18:55:28 +02:00
Jason A. Donenfeld d8bad72fd6 preferences: add donation link
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-10-12 18:55:28 +02:00
Jason A. Donenfeld 927b32c99f libwg-go: update to go 1.13
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-10-12 18:55:21 +02:00
Jason A. Donenfeld 27b691bef6 idea: update settings for 3.5
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-10-12 16:51:15 +02:00
Harsh Shandilya d2b9de740d Migrate to Android 10
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2019-09-30 19:45:11 +02:00
Jason A. Donenfeld eb45b4b1bd InetAddresses: prepare for Android 10's real method support
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-09-30 19:42:02 +02:00
Harsh Shandilya c545b5e65f FragmentUtils: Directly cast context as SettingsActivity
ContextThemeWrapper#getContext seems to be an instance of ContextImpl now which
is not public API and also not what we want. Directly cast context as SettingsActivity
which seems to work exactly how we need this to.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2019-09-27 17:26:56 +05:30
Harsh Shandilya 992b6486a1 Update runtime dependencies
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2019-09-27 13:27:51 +05:30
Harsh Shandilya 421b1f889b Add LeakCanary to debug builds
LeakCanary is an advanced memory leak detection library for Android designed by the fine folks
at Square.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2019-09-27 13:18:27 +05:30
Harsh Shandilya 1ee1368e18 Fix activity leak on Android Q
This workaround was discussed at https://twitter.com/Piwai/status/1169274622614704129 after
Google had closed the issuetracker with a WONTFIX at https://issuetracker.google.com/issues/139738913.

The situation has since changed with Google promising a fix on October's ASB but since we can't really
know, patch this ourselves for the timebeing.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2019-09-27 13:18:27 +05:30
Harsh Shandilya 1a6a8789c1 Update to Golang 1.12.10
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2019-09-27 13:15:06 +05:30
Harsh Shandilya b5c155db1b Update AGP to 3.5.0
Also update the gitignore to ignore the '.cxx' directory AGP 3.5.0
uses for native build artifacts.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2019-09-27 13:15:06 +05:30
Harsh Shandilya 6c5b46eadd Uprev to Gradle 5.6.2
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2019-09-27 12:59:53 +05:30
Jason A. Donenfeld 5abbab2635 Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-07-08 15:46:39 +02:00
Jason A. Donenfeld e5766094f4 tools: bump deps
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-07-08 15:46:04 +02:00
Jason A. Donenfeld 96d77988d3 Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-06-05 21:08:47 +02:00
Revath S Kumar e9e4fd4e8b TunnelList: Get focus to toggle button via remote for Fire TV
This removes a no-longer-needed workaround for the ListView
OnItemClickListener (it won't fire if a focusable view is inside the
item view). Since converting our ListView instances to RecyclerView
instances, we set the OnClick and OnLongClick listeners directly on the
item view, and this workaround no longer has any effect.

Unsurprisingly, the workaround breaks focusability of the Switch, which
is necessary to toggle tunnels on devices with keypad-based navigation,
such as the Fire TV.

This commit also adds explicit focusability hints for the Switch.

Related mail thread:
https://lists.zx2c4.com/pipermail/wireguard/2019-May/004112.html

Reported-by: Christophe-Marie Duquesne <chmd@chmd.fr>
Reported-by: Revath S Kumar <gmail@revathskumar.com>
[Samuel: sorted attributes; expanded commit message]
Signed-off-by: Samuel Holland <samuel@sholland.org>
2019-06-05 21:07:50 +02:00
Jason A. Donenfeld b5d9fbf1f4 libwg-go: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-06-05 21:07:50 +02:00
Jason A. Donenfeld 81dc89f85b Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-03-19 00:56:13 -06:00
Jason A. Donenfeld 76305045db InetEndpoint: properly match IPv6 addresses
The old one didn't account for trailing digits.

Reported-by: Brandon Jackson <bjackson@napshome.net>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-03-19 00:53:14 -06:00
Jason A. Donenfeld c4ba48d7a9 libwg-go: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-03-19 00:40:45 -06:00
Jason A. Donenfeld d5dcdf13bf strings: %i is invalid
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-03-19 00:30:53 -06:00
Jason A. Donenfeld 7feb3dccbf WgQuickBackend: pass result to error string
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-03-16 12:24:28 -06:00
Jason A. Donenfeld 2251d74fce Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-03-08 01:41:41 +01:00
Jason A. Donenfeld 2c89d3fa7f libwg-go: use netpoll rather than rwcancel
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-03-07 02:05:42 +01:00
Jason A. Donenfeld 49cc634678 libwg-go: don't use submodule
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-03-03 05:43:42 +01:00
Jason A. Donenfeld c93e81c632 libwg-go: update to 1.12
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-02-27 05:24:25 +01:00
Jason A. Donenfeld 050e202291 project: bump dependencies
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-02-17 04:14:11 +01:00
Jason A. Donenfeld efe04d6602 ToolsInstaller: fix typo on cleanup
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-02-17 03:32:35 +01:00
Jason A. Donenfeld 823b8324c7 Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-02-15 18:03:43 +01:00
Jason A. Donenfeld ae2f88a9ee tools: bump upstream version
This now includes the latest ARM64 ChaCha20 implementation, which should
improve performance.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-02-14 11:59:10 +01:00
Jason A. Donenfeld 32287c60c4 ToolsInstaller: Require Magisk 18
People installing magisk modules are people capable of updating Magisk.
No need to leave around old compat cruft.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-02-14 11:59:10 +01:00
Harsh Shandilya 69c6fa0a24 ToolsInstaller: Use chcon over restorecon
restorecon probes file_contexts to get the context
to be applied to the file. /sbin/.magisk does not
exist in file_contexts for obvious reasons so restorecon
always fails. Use chcon directly with the system_file
context to allow contexts to be applied.

Suggested-by: Chris Renshaw <osm0sis@outlook.com>
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2019-02-14 11:03:41 +01:00
Jason A. Donenfeld c3e63df7b5 Update copyright
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-01-07 19:21:34 -05:00
Samuel Holland fb4f1e30d5 PeerProxy: Only add IPv4 DNS servers when excluding private IPs
Reported-By: Christophe-Marie Duquesne <chmd@chmd.fr>

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-01-07 19:21:34 -05:00
Harsh Shandilya 6d0fde218b Bump stream support libraries to latest stable
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-12-18 17:58:55 +01:00
Jason A. Donenfeld 6d02b0a26d strings: squelch warning on multiple %s
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-12-18 17:58:12 +01:00
Harsh Shandilya 495bf9c954 Enable proguard and wire up rules
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-12-18 22:18:00 +05:30
Jason A. Donenfeld cb1bc95e6b Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-12-18 17:07:04 +01:00
Harsh Shandilya 6fdf0266cf Migrate to AndroidX
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-12-18 16:54:54 +01:00
Jason A. Donenfeld ee26198e2c Bump the go runtime
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-12-16 01:54:22 +01:00
Jason A. Donenfeld fe424197da InetEndpoint: disallow huge ports
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-12-15 22:05:43 +01:00
Samuel Holland 053ca232aa Adjust code generation to match existing style
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-12-15 14:46:23 -06:00
Samuel Holland 2e8d566bd4 Clean up error messages
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-12-15 14:46:23 -06:00
Samuel Holland dcb0e9b3e8 Provide semantically meaningful exceptions for translation
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-12-15 14:46:23 -06:00
Jason A. Donenfeld 3497882ea6 Bump the go runtime
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-12-15 06:13:55 +01:00
Jason A. Donenfeld dc2463a0ab Fix locale usage
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-12-11 03:47:32 +01:00
Jason A. Donenfeld b514717076 Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-12-11 02:38:18 +01:00
Jason A. Donenfeld 23932952d8 Squelch xml warning
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-12-11 02:38:18 +01:00
Jason A. Donenfeld 266ee7626c Throw illegalargumentexception instead of nullpointerexception for builder errors
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-12-11 02:28:34 +01:00
Zachary Wander c1ba1f409c Unwrap the correct exception
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-12-11 02:21:37 +01:00
Jason A. Donenfeld 0f669e8ca3 Order strings
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-12-11 02:21:37 +01:00
Zachary Wander 9de711a4f5 Localize exception messages
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-12-11 02:21:23 +01:00
Jason A. Donenfeld e1965f121c Lowercase endpoint in exception message
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-12-11 01:02:55 +01:00
Jason A. Donenfeld b2c9b3500c Do not allow for an empty port in endpoint
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-12-10 15:54:38 +01:00
Jason A. Donenfeld f60d26c4bf Export actual configuration for zips
Reported-by: John Greenwood <ijohnyyh@gmail.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-12-10 15:47:16 +01:00
Jason A. Donenfeld b43044fee9 Add upstream go patch for lstat
Android O disallows lstat, and this upstream golang patch hasn't made it
into a release yet.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-12-10 04:33:45 +01:00
Jason A. Donenfeld 2bc66e4574 Bump go submodule
Fixes a problem with inotify_init being blocked by Android 9's seccomp
policy.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-12-10 02:56:51 +01:00
Jason A. Donenfeld a641a093ad Use English lower casing
In Turkish, I becomes ı instead of i, which is a problem when matching
things like "AllowedIPs".

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-12-09 05:54:47 +01:00
Jason A. Donenfeld 704369d431 Version bump
I feel a bit uneasy releasing this, because who knows how much Samuel
has tested his model rewrite, but nothing looks obviously horrible, so
let's give it a shot. We're still "alpha", after all.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-12-08 03:51:42 +01:00
Jason A. Donenfeld 5aa8191cd3 Do not close zip input stream
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-12-08 03:48:50 +01:00
Jason A. Donenfeld bb43804d58 Downgrade support library
We're not ready for the newer one yet, but we will be soon if all goes
well.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-12-08 03:19:54 +01:00
Jason A. Donenfeld 7a8d14c85c Remove ACRA
This was requested by developers who never wound up using it. It's not
really worth keeping around, since the play console gives us most of
what we need anyway.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-12-08 03:17:19 +01:00
Samuel Holland d1e85633fb Remodel the Model
- The configuration and crypto model is now entirely independent
of Android classes other than Nullable and TextUtils.
- Model classes are immutable and use builders that enforce the
appropriate optional/required attributes.
- The Android config proxies (for Parcelable and databinding) are
moved to the Android side of the codebase, and are designed to be
safe for two-way databinding. This allows proper observability in
TunnelDetailFragment.
- Various robustness fixes and documentation updates to helper classes.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-12-08 02:39:41 +01:00
Samuel Holland a264f7ab36 Auto-format the source directories
Blame Jason for writing Java in vim.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-11-11 21:50:23 -06:00
Jason A. Donenfeld 4e134772d7 tools: wg-quick: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-11-11 22:16:28 -05:00
Jason A. Donenfeld 3eb6c91c9e libwg-go: do not mix C style and Go style variable names
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-11-06 15:43:09 +01:00
Jason A. Donenfeld e7fd53b809 libwg-go: don't forget to include jni calls
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-11-03 20:17:19 +01:00
Jason A. Donenfeld 164ec1e31d Bump version so that we have correct submodule hashes
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-11-01 03:41:56 +01:00
Jason A. Donenfeld 373a5f18d6 tools: update submodules
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-10-30 01:01:49 +01:00
Jason A. Donenfeld 36058ead7d Never use system go
Telling people to patch their system go is bonkers.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-10-11 00:23:17 +02:00
Jason A. Donenfeld 33fd5b4634 Update to go modules
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-10-09 19:46:48 +02:00
Jason A. Donenfeld 91647978e6 Fix small error
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-10-01 17:54:47 +02:00
Jason A. Donenfeld d0b64f4bd5 Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-10-01 17:47:24 +02:00
Jason A. Donenfeld c23d58bc27 Peer: prefer v4 endpoints to v6
This works around DNS64 XLAT changeovers.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-10-01 17:13:14 +02:00
Jason A. Donenfeld 49a9475c4a strings: properly mark positionals
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-10-01 16:33:37 +02:00
Jason A. Donenfeld 364032fe84 Update gradle and external deps
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-10-01 16:30:07 +02:00
Jason A. Donenfeld 5658584803 global: update copyright headers
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-09-06 21:32:46 -06:00
Jason A. Donenfeld d580200989 Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-08-26 11:15:23 -06:00
Jason A. Donenfeld c2cdde73d1 tools: bump submodules
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-08-26 11:09:36 -06:00
Jason A. Donenfeld bc74d4d7f8 libwg-go: update golang version
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-08-26 11:08:45 -06:00
Harsh Shandilya 535c611f2d QuickTileService: Don't use deprecated getDrawable method
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-08-26 11:04:01 -06:00
Harsh Shandilya 6efbf65405 Target SDK 28
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-08-26 11:04:01 -06:00
Harsh Shandilya abb121224d FragmentUtils: Make final and prevent instantiation
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-08-26 11:04:01 -06:00
Harsh Shandilya 8ad4657d6f Sort dependencies
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-08-26 11:04:01 -06:00
Harsh Shandilya 6d3f1e00a5 Supress false-positive DefaultLocale warnings
We decided in 402472237e8f that it's a bad idea for our use-case

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-08-26 11:04:01 -06:00
Harsh Shandilya c38f6c471d Extract error messages to string resources
Useful for validation errors and localisation later on

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-08-26 11:04:01 -06:00
Jason A. Donenfeld 85462de254 MonkeyedSnackbar: remove
This didn't actually help with much and caused problems.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-08-26 10:51:21 -06:00
Zhao Gang 61d4f17f5d config: fix wrong Peer endpoint string format
When a tunnel is running, saving the tunnel's config with an IPv6
address endpoint like [::1]:42 would result in the wrong format ::1:42.
This patch fixes it.

For endpoints with an IPv6 address(e.g. [::1]:42). Since the default
endpoint InetSocketAddress is created unresolved, getEndpointString()
returns "[::1]:42" (InetSocketAddress.getHostString() returns the
literal hostname). After the endpoint is resolved, getEndpointString()
returns "::1:42" (InetSocketAddress.getHostString() returns the IPv6
address without the square brackets). This inconsistent return values
caused the above mentioned bug.

With this patch, function getEndpointString would return the right
format string whether the endpoint is resolved or not.

Signed-off-by: Zhao Gang <gang.zhao.42@gmail.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-08-16 12:08:09 -07:00
Jason A. Donenfeld 09cf73cd3c GoBackend: make socket IPC optional
This fixes the multi-user case, which cannot be determined at compile
time and probably isn't reasonable to consider anyway in a global
manner.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-31 14:27:29 +02:00
Jason A. Donenfeld ffa3cefa67 Style: use attrs from appcompat rather than from frameworks
This isn't possible for colorForeground, colorBackground,
textAppearanceMedium, but at least it's useful for some things here.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-30 22:41:55 +02:00
Jason A. Donenfeld 8ec2cc8582 FloatingActionsMenu: don't wrap context on asus api 21
Works around frameworks bug.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-30 17:35:08 +02:00
Jason A. Donenfeld 75dfa0643b Show different color for multiselection
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-30 16:28:03 +02:00
Jason A. Donenfeld d5cde43158 Replace hard-coded colors with theme colors
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-30 14:43:56 +02:00
Harsh Shandilya 6493a9a1f2 Remove placeholder color and directly use alpha
Why wasn't this done like this in the first place?

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-07-30 14:28:27 +02:00
Jason A. Donenfeld f35e059194 MonkeyedSnackbar: fix typos
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-29 19:17:10 +02:00
Jason A. Donenfeld 3cb3e9d8b7 Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-29 18:52:54 +02:00
Jason A. Donenfeld 5dfc5659ad ConfigNamingDialog: use name input filter
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-29 18:44:30 +02:00
Jason A. Donenfeld c4102992ae MonkeyedSnackbar: work around Harsh's broken phone
I think I'd probably like to revert this, since presumably there's a
good reason in the first place why the support lib disables animations
when accessibility services are turned on?

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-29 18:35:26 +02:00
Jason A. Donenfeld 219f4e8016 MSF: make it more obvious what needs to be done
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-29 17:21:30 +02:00
Jason A. Donenfeld 6558140a7c FloatingActionButtonBehavior: animate transitions
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-29 17:21:30 +02:00
Jason A. Donenfeld db7b61ab80 Roll back to API 27 for now
There's no source available for API 28, which is a pain. But this commit
should be reverted whenever source is released.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-29 16:01:44 +02:00
Jason A. Donenfeld bce5d852e1 Target API 28
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-29 15:46:01 +02:00
Jason A. Donenfeld b960b4a6cd TunnelListFragment: show selected tunnel
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-29 05:57:53 +02:00
Jason A. Donenfeld 1b10e75168 TunnelListFragment: fix multiselection on rotation
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-29 04:50:16 +02:00
Jason A. Donenfeld 07359e392c FloatingActionButonBehavior: set translation back to 0 when snackbar dies
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-29 04:23:30 +02:00
Jason A. Donenfeld e5a5bad240 MainActivity: only show two column on tablets
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-29 03:46:45 +02:00
Samuel Holland ca92ac60b7 MainActivity: Fix fragment selection logic
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-07-28 17:07:37 -05:00
Jason A. Donenfeld e29c21f8df Application: refuse to run on old android
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-28 18:27:45 +02:00
Jason A. Donenfeld 6ceeac93bf QuickTileService: fix bug the wrong way
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-28 17:55:24 +02:00
Jason A. Donenfeld 9f861096ac config: show more informative error message on wrong key
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-27 15:20:23 +02:00
Jason A. Donenfeld 520df16885 Set ACRA install source
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-26 13:46:18 +02:00
Jason A. Donenfeld c905ef6083 Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-26 05:29:49 +02:00
Eric Kuck 9652fe99df TunnelDetailFragment now restores state correctly after process death
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-26 05:17:43 +02:00
Jason A. Donenfeld 62d8beff96 Application: use proper completablefuture for backend
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-26 04:54:14 +02:00
Jason A. Donenfeld 7d438e9dbc Wire up ACRA
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-26 01:41:29 +02:00
Harsh Shandilya b364221c93 FloatingActionBehaviour: Adjust constructors
Get these in line with the parent class

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-07-26 01:36:53 +02:00
Jason A. Donenfeld b8052bd8fb ThemeChangeAwareActivity: reintroduce cache buster
This is still needed by certain icons, like the trash icon in the peer
editor.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-25 04:05:41 +02:00
Jason A. Donenfeld e437ac389e Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-25 03:11:33 +02:00
Jason A. Donenfeld 2db2a0921d MainActivity: attempt to fix commit state exceptions
This is an attempt to fix:

java.lang.IllegalStateException:
at android.support.v4.app.FragmentManagerImpl.checkStateLoss (FragmentManager.java:2053)
at android.support.v4.app.FragmentManagerImpl.enqueueAction (FragmentManager.java:2079)
at android.support.v4.app.BackStackRecord.commitInternal (BackStackRecord.java:678)
at android.support.v4.app.BackStackRecord.commit (BackStackRecord.java:632)
at com.wireguard.android.activity.MainActivity.moveToState (MainActivity.java:58)
at com.wireguard.android.activity.MainActivity.onSelectedTunnelChanged (MainActivity.java:157)
at com.wireguard.android.activity.BaseActivity.setSelectedTunnel (BaseActivity.java:75)
at com.wireguard.android.fragment.BaseFragment.setSelectedTunnel (BaseFragment.java:82)
at com.wireguard.android.fragment.TunnelListFragment.lambda$null$4$TunnelListFragment (TunnelListFragment.java:307)
at com.wireguard.android.fragment.TunnelListFragment$$Lambda$4.onClick (Unknown Source:6)
at android.view.View.performClick (View.java:6274)
at android.view.View$PerformClick.run (View.java:24729)
at android.os.Handler.handleCallback (Handler.java:789)
at android.os.Handler.dispatchMessage (Handler.java:98)
at android.os.Looper.loop (Looper.java:169)
at android.app.ActivityThread.main (ActivityThread.java:6595)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:240)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:767)

But this is probably the wrong way to fix it and instead moveToState
needs to be reimagined.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-25 03:07:16 +02:00
Jason A. Donenfeld d7889c4e88 style: coloring the navbar looks a bit strange when rotated
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-25 02:59:26 +02:00
Jason A. Donenfeld 559add3f71 TunnelEditorFragment: plug memory leak on listeners
Apparently these don't get GC'd unless they're removed explicitly,
because there's a global singleton registry of them. So, introduce a
little registry of our own.

Reported-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-25 02:59:26 +02:00
Jason A. Donenfeld d615304e83 qrcode: minor adjustments
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-25 02:59:26 +02:00
Eric Kuck 8e0835e570 Added QR code scanner as tunnel import method
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-25 02:05:11 +02:00
Harsh Shandilya bb20c89cd5 tools: Bump wireguard submodule
This force pushing is going to be the death of me

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-07-24 18:26:53 +02:00
Jason A. Donenfeld 996cbb5f2b tools: support ancient NDKs
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-24 18:09:18 +02:00
Jason A. Donenfeld 8028d708cb tools: let wg(8) play with userspace implementation
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-24 17:57:56 +02:00
Harsh Shandilya 7689905c78 config: Remove Locale based string format
The configurations are supposed to be in a very specific
format which is not user-facing and hence doesn't have to
be adjusted for locale avoiding both the redundancy as well
as potential breakages in the configuration file format from
different locales.

Fixes: 71c67aa24ae2 ("config: Minor cleanup")
Reported-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-07-24 17:57:56 +02:00
Jason A. Donenfeld 284e42647c tools: pass in debug package name
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-24 17:57:56 +02:00
Jason A. Donenfeld 3a16c08821 Make placeholder pretty
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-23 00:05:12 +02:00
Harsh Shandilya 76fb6a318e Show help text when no tunnels are imported
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-07-22 23:21:17 +02:00
Jason A. Donenfeld c633f96374 FloatingActionsMenuRecyclerViewScrollListener: add final modifiers
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-22 23:21:17 +02:00
Harsh Shandilya 3357be9557 RTL layout fixes
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-07-22 18:21:39 +02:00
Harsh Shandilya 6696e838da treewide: Optimize imports
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-07-22 18:20:23 +02:00
Jason A. Donenfeld d0d56f3a1b fab: move in direct ratio to scroll
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-20 16:41:53 +02:00
Jason A. Donenfeld fbf32a6c29 Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-20 15:54:46 +02:00
Harsh Shandilya 3e37289b68 UI: use background color for navbar in dark mode
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-07-20 15:53:41 +02:00
Jason A. Donenfeld 2d6a45f824 fab: make icons always white
With the new shade of blue, perhaps this simply looks better.

I don't like hard coding the color away from the theme, however.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-20 15:45:21 +02:00
Jason A. Donenfeld ed802336e6 theme: use less disgusting color
Harsh's "users" were offended by the dark theme. So, we change the
accent to that used by gboard's dark theme, which should be pretty
uncontroversial.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-20 03:23:17 +02:00
Harsh Shandilya b1d1e3b436 TunnelListFragment: Allocate interpolators outside scroll listener
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-07-20 03:17:49 +02:00
Jason A. Donenfeld d33e322b67 TunnelEditorFragment: fix null pointer dereference
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-19 20:57:00 +02:00
Jason A. Donenfeld 60a6e29350 QuickTileService: fix null pointer dereference
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-19 20:57:00 +02:00
Jason A. Donenfeld 3b0e0c2f16 tools: bump version
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-18 21:54:14 +02:00
Jason A. Donenfeld ffb8bccbc5 Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-18 18:40:16 +02:00
Jason A. Donenfeld 08170f7e55 TunnelListFragment: setOnScrollListener is old, but we support API 21, so we have to use it
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-18 18:32:42 +02:00
Jason A. Donenfeld 28d47b3470 AppListDialogFragment: getArguments is null before onCreate
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-18 18:08:08 +02:00
Jason A. Donenfeld 8e3586328c fab: use auto calculated fling threshold
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-18 02:32:05 +02:00
Jason A. Donenfeld f315654d40 fab: add fab sized padding at bottom of recycler view
This way we can keep scrolling when there are exactly the right number
of items, so that the toggle switch becomes visible.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-18 02:15:14 +02:00
Harsh Shandilya fdfab18d45 fab: make fab respond to recyclerview scroll events
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-07-18 02:15:06 +02:00
Harsh Shandilya d43e77867c fab: slide fab up when a snackbar shows
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-07-18 02:15:06 +02:00
Harsh Shandilya df03bdd7f9 android: QuickTileService: Do not use slashed icon on Android P
Android P features circle masked QS tiles which make use of colors
to denote STATE_ACTIVE/STATE_INACTIVE rather than a slash across
the drawable as seen on Android Oreo.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-07-16 17:31:14 +02:00
Jason A. Donenfeld ae5bf6fbb2 Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-16 15:05:18 +02:00
Jason A. Donenfeld 04ff63f1b5 InetAddresses: unwrap reflection exceptions
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-16 15:05:18 +02:00
Harsh Shandilya 71cf39660f android: TunnelListFragment: Annotate parameter to match super method
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-07-16 03:26:02 +02:00
Jason A. Donenfeld 7364f2540e BaseFragment: do not allow tunnel to be null
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-13 04:13:35 +02:00
Jason A. Donenfeld 5d66f6b2e5 config: dns servers can be null
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-13 04:09:09 +02:00
Jason A. Donenfeld fec5fa8caf config: make loadData private
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-13 04:06:55 +02:00
Jason A. Donenfeld 6f48e138a4 TunnelEditorFragment: binding might be null
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-13 04:04:11 +02:00
Jason A. Donenfeld 21c15fe4ea QuickTileService: show intermediate state when changing
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-13 03:57:02 +02:00
Eric Kuck 67ea8b2936 global: Add nullity annotations
Signed-off-by: Eric Kuck <eric@bluelinelabs.com>
2018-07-13 03:46:23 +02:00
Jason A. Donenfeld fbaa4d9ab1 Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-12 02:14:25 +02:00
Harsh Shandilya 19b57c41b7 Address lint issues in TunnelListFragment
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-07-12 02:07:19 +02:00
Jason A. Donenfeld 26d762bc5c TunnelEditorFragment: add DNSes to allowedIPs when excluding rfc1918
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-12 02:04:52 +02:00
Jason A. Donenfeld eab0248aaa Clean up warnings
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-11 21:03:22 +02:00
Jason A. Donenfeld a5bbe171cb fab: remove asus hack
Let's hope Eric's changes make this no longer required.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-11 21:03:22 +02:00
Eric Kuck 5463086e75 fab: use support library's rendering
Signed-off-by: Eric Kuck <eric@bluelinelabs.com>
2018-07-11 21:03:22 +02:00
Jason A. Donenfeld 1f7bdd4f5f Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-10 22:00:10 +02:00
Jason A. Donenfeld 3cf6aad083 QuickTileService: automatically slash the tile
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-09 18:55:55 +02:00
Jason A. Donenfeld b997a2581b BaseFragment: in the event no view is available, use toast
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-09 17:29:35 +02:00
Eric Kuck d7ea078cdf Request VPN permissions on activation
Signed-off-by: Eric Kuck <eric@bluelinelabs.com>
2018-07-09 17:08:41 +02:00
Jason A. Donenfeld d50e0f5fb9 Use instanceOf instead of getClass
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-08 23:59:25 +02:00
Eric Kuck c696e9f275 Build with different name and ID in debug mode
Signed-off-by: Eric Kuck <eric@bluelinelabs.com>
2018-07-08 03:26:42 +02:00
Jason A. Donenfeld 707c8c19a8 gradle: bump build tools version
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-08 03:18:15 +02:00
Eric Kuck b37b48b8dc Switch from ListView to RecyclerView
Signed-off-by: Eric Kuck <eric@bluelinelabs.com>
2018-07-08 02:50:49 +02:00
Jason A. Donenfeld 2c7203ab8d Another bump for misbuild
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-06 21:13:36 +02:00
Jason A. Donenfeld d1a812042c Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-06 18:17:58 +02:00
Jason A. Donenfeld 78d976162d PeerEditor: put exclusion checkbox next to label
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-06 18:17:58 +02:00
Jason A. Donenfeld 7078162c69 AppListDialogFragment: add deselect all button
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-06 18:17:58 +02:00
Jason A. Donenfeld 2742b09b5a tools: update wg-quick for ExcludedApplications support
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-06 18:17:58 +02:00
Jason A. Donenfeld 7b28d51cdd global: move to Apache 2.0
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-06 16:28:46 +02:00
Jason A. Donenfeld d132087b3c PeerEditor: add exclude private IPs functionality
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-06 16:28:46 +02:00
Jason A. Donenfeld 124f186983 TunnelEditor: fix nits
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-06 16:28:46 +02:00
Eric Kuck 500a705531 AppListDialogFragment: add implementation for excluding applications
Signed-off-by: Eric Kuck <eric@bluelinelabs.com>
2018-07-06 04:14:19 +02:00
Jason A. Donenfeld 5729947d6c TunnelEditor: better looking buttons
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-07-06 02:40:11 +02:00
Harsh Shandilya 363d0b9126 android: model: Make some methods static
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-06-30 21:19:59 +02:00
Harsh Shandilya e985452f3b android: FloatingActionsMenu: Don't create labels on ASUS' Android 5 devices
They have completely wrecked the framework there and all efforts to
work around their absolutely broken software have been in vain, hence
let's atleast let users be able to use the app, labels or otherwise.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-06-30 21:10:52 +02:00
Harsh Shandilya 5c9643a23b android: VersionPreference: Handle no-browser-installed case
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-06-30 21:10:22 +02:00
Harsh Shandilya 0e3e3ae37b android: Add select all button to action mode
Thanks to Jason for suggesting the not-clinically-insane
method to go about this.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-06-30 21:07:24 +02:00
Harsh Shandilya b41d473f64 wireguard: Bump snapshot
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-06-30 21:06:40 +02:00
Jason A. Donenfeld 3de549d2c7 Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-25 16:18:57 +02:00
Jason A. Donenfeld 408e9004b0 libwg-quick: add iptables output allowance
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-25 16:16:27 +02:00
Jason A. Donenfeld e1a66d5766 global: Small cleanups
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-25 16:10:02 +02:00
Harsh Shandilya 99cf2152c4 android: Consolidate getPrefActivity into FragmentUtils
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
[Samuel: Changed static to non-static import]
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-06-23 01:00:07 -05:00
Harsh Shandilya 53e8d425e9 QuickTileService: Remove useless override
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-06-23 00:57:31 -05:00
Harsh Shandilya 9e5f45da15 gradle: Style
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-06-23 00:57:31 -05:00
Harsh Shandilya 4c0caa10e9 treewide: Optimize imports
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-06-23 00:57:31 -05:00
Samuel Holland b9991e4229 config: Refactor IPCidr and use of InetAddress
Use a canonically-named utility class to tack on methods to the existing
InetAddress class. Rename IPCidr to InetNetwork so it better matches
InetAddress and is more pronouceable :) While here, simplify the
constructor and toString() functions, and properly implement hashCode().

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-19 21:59:44 -05:00
Samuel Holland 4acee49d4b util: Extract non-Android utility interfaces
As part of a refactoring that will likely introduce more custom
collection classes, move the non-Android-specific parts outside the
com.wireguard.android package.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-19 21:59:44 -05:00
Samuel Holland d3a8291a7a crypto: Slightly Java-ify the Curve25519 implementation
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-19 21:59:42 -05:00
Samuel Holland bcae77b989 app: Regularly scheduled gradle updates
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-19 21:35:54 -05:00
Samuel Holland de75ff4bea idea: Disable an unwanted inspection
Android Studio isn't smart enough to realize that the public/private
keys and the keypair are effectively the same thing. Just turn off the
inspection because it's usually tripped by intentional things.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-19 21:33:36 -05:00
Jason A. Donenfeld b10a6171a5 Application: make lock final
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-17 22:34:22 +02:00
Jason A. Donenfeld 6534f45a3a application: style fix
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-17 14:53:31 +02:00
Jason A. Donenfeld 373145d30e Version bump for clat fix
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-17 05:25:42 +02:00
Jason A. Donenfeld 5feea74f28 Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-14 05:07:15 +02:00
Jason A. Donenfeld e8891d775b global: supply backend asynchronously
We can't block for IO, so move everything to async workers or to
callbacks.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-14 05:06:18 +02:00
Jason A. Donenfeld 0f128f99a1 Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-12 05:46:02 +02:00
Jason A. Donenfeld 61e3441bfb Application: require rootshell to use wgquick backend
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-12 05:42:24 +02:00
Jason A. Donenfeld 15e10d8fde ToolsInstaller: safer state machine
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-10 05:17:09 +02:00
Jason A. Donenfeld ea72e8b656 Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-07 04:59:47 +02:00
Jason A. Donenfeld 2ca27c2783 BaseActivity: style
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-07 04:49:15 +02:00
Jason A. Donenfeld f190db0754 BootShutdownReceiver: style
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-07 04:37:28 +02:00
Jason A. Donenfeld 8d27570eea Backend: abstract version information
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-07 04:35:07 +02:00
Jason A. Donenfeld 24605c9c01 Give Samuel heart attack by removing Dagger
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-07 04:12:42 +02:00
Jason A. Donenfeld 7b59353910 VersionPreference: account for checking state and move away from tools installer
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-07 03:27:06 +02:00
Jason A. Donenfeld ca7f4e5be9 FloatingActionMenu: 5.1 requires explicit text color
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-06 03:12:29 +02:00
Harsh Shandilya ab95ac83c9 MainActivity: Fix style
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-06-06 02:07:26 +02:00
Jason A. Donenfeld 51fb57433b ToolsInstallerPreference: do not check for magisk on main thread
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-06 00:29:44 +02:00
Harsh Shandilya 0496b94aa8 build: Allow building release artifacts in-tree
This change avoids all need for changing any file under
VCS to insert signing keys and configs for release builds.

Example contents of keystore.properties

```
// Location of keystore, relative to module build.gradle,
// in this case, of the app module
storeFile=../wireguard.jks
storePassword=b3ty0uc4nth4xxth1s
keyAlias=wireguard
keyPassword=4ndr01dsux
```

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-06-05 19:58:34 +05:30
Harsh Shandilya d8d6e99df1 MainActivity: Silence useless warning
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-06-05 19:52:08 +05:30
Jason A. Donenfeld 377ba1c9d1 Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-05 16:07:56 +02:00
Jason A. Donenfeld 8ebeeb6d90 FloatingActionMenu: use appcompat theme
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-05 16:01:38 +02:00
Harsh Shandilya 3c3de065c6 MainActivity: collapse action menu on toolbar touch
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-06-05 15:22:40 +02:00
Jason A. Donenfeld a17ec6b1f7 ToolsInstaller: allow installing as Magisk module
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-05 06:17:00 +02:00
Jason A. Donenfeld cbf8ac6538 libwg-go: better error when using unpatched Go
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-05 03:28:16 +02:00
Jason A. Donenfeld d4b1295e94 ActionBar: show single menu item as toolicon
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-05 03:09:51 +02:00
Jason A. Donenfeld db53e17e58 TunnelListFragment: hide menu when going to settings
Really the menu should be hidden when clicking on the action bar, too.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-05 03:05:58 +02:00
Jason A. Donenfeld f0a3e63743 MainActivity: style
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-05 02:47:59 +02:00
Jason A. Donenfeld d636e13717 fab: properly get theme color
Harsh changed this before, but my original way is what the support
library does internally.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-05 02:44:32 +02:00
Jason A. Donenfeld dea60e13c0 libwg-go: more efficient and safer string passing
It was unclear when the Go string was actually freed.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-05 02:18:12 +02:00
Harsh Shandilya 40a30d997d fab: Remove useless override
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-06-05 02:05:35 +02:00
Harsh Shandilya dba8d0305e fab: Use themed context to set style
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-06-05 02:05:23 +02:00
Jason A. Donenfeld 27072972ab DarkMode: move to shared preferences listener
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-05 02:02:09 +02:00
Jason A. Donenfeld d56e95c576 MainActivity: style
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-04 19:55:27 +02:00
Jason A. Donenfeld d0ef2c43d9 FloatingActionsMenu: remove unused imports
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-04 19:12:12 +02:00
Jason A. Donenfeld 0c0c1acc3b BaseActivity: support android 5 and 6 when clearing drawable cache
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-04 18:35:18 +02:00
Jason A. Donenfeld 48f796c463 LogExporterPreference: get all past processes
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-04 17:57:02 +02:00
Jason A. Donenfeld 8aab35a70d BaseActivity: invalidate icon cache on Android P
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-04 17:57:02 +02:00
Jason A. Donenfeld e5f6c24174 Bump version
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-04 07:16:10 +02:00
Jason A. Donenfeld 4cad06b7ce app: disable proguard
It's mostly a hindrance to debugging.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-04 07:16:10 +02:00
Jason A. Donenfeld c4e32328fc TunnelManager: disable dangerous intents for now
We need to think about how to allow this securely. It's not okay for all
apps to be allowed to twiddle with VPN settings.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-04 07:06:28 +02:00
Jason A. Donenfeld a2ccbf003c TunnelManager: new intents
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-04 07:06:28 +02:00
Jason A. Donenfeld 10ca2c8681 Preferences: don't use round icon
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-03 16:15:30 +02:00
Harsh Shandilya fd63e496e5 Preferences: Move version pref to top and add icon
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-06-02 19:35:11 +02:00
Jason A. Donenfeld 567503abc7 Backends: print versions somewhere in log
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-02 19:26:33 +02:00
Harsh Shandilya 4671f59c67 android: Cleanup classes
- Use final modifer wherever possible
- Use try-with-resources for input/output streams

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-06-02 19:14:56 +02:00
Harsh Shandilya 4986d92f3d crypto: KeyEncoding: Fix style
- Replace python style variable names with camel case
- Don't declare multiple variables in the same line

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-06-02 19:12:30 +02:00
Jason A. Donenfeld 0b1c7cc35f Topic: John does things differently
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-02 18:44:35 +02:00
Jason A. Donenfeld 9e278c88e6 ExporterPreferences: disable control immediately
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-02 18:38:56 +02:00
Jason A. Donenfeld c3246060f5 Preferences: add log exporter
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-02 18:35:09 +02:00
Jason A. Donenfeld b7e025e381 libwg-go: fix style
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-01 18:27:30 +02:00
Jason A. Donenfeld 858ec4c0ab Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-01 18:01:25 +02:00
Jason A. Donenfeld 65292aaa79 Topic: make reentrant
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-01 17:34:59 +02:00
Jason A. Donenfeld 3d57eb633e BaseActivity: flush themed icon cache on theme change
The most terrible hack you have ever seen.

The drawable cache isn't properly flushed when changing the theme -- a
frameworks bug, evidently -- so we work around it by digging deep into
the mud.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-01 16:48:08 +02:00
Jason A. Donenfeld 1e45898d70 Settings: add version
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-01 16:06:56 +02:00
Jason A. Donenfeld 61431fb579 colors: final touches
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-01 15:18:23 +02:00
Harsh Shandilya 00d48e867b ui: Use better list colors in night mode
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-06-01 18:42:20 +05:30
Harsh Shandilya d5df0c10ab TunnelListFragment: Dejank action mode title
When unselecting items, the toolbar briefly says
'0 items selected' before it reverts back to the
non-action mode toolbar which feels janky at best.

To mitigate this, just set a blank title to the action
mode toolbar when item count is 0, to facilitate the
smoothness of the transition to non-action mode toolbar.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-06-01 18:42:20 +05:30
Harsh Shandilya af814951f3 fab: Make label responsive to night mode
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-06-01 18:42:20 +05:30
Harsh Shandilya a54a03aa2f FloatingActionButton: Cleanup declaration of TranslucentLayerDrawable class
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-06-01 18:42:20 +05:30
Harsh Shandilya 4edfdd8f3b FloatingActionButton: Make attribute grabbing not be terrible
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-06-01 18:42:19 +05:30
Jason A. Donenfeld 32d669a661 theme: add dark theme with toggle
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-01 14:57:25 +02:00
Jason A. Donenfeld 918076a670 global: fix theme situation and clean up cruft while adding more cruft
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-06-01 14:57:25 +02:00
Harsh Shandilya 752e61d1c7 fab: default to app theme colors
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-06-01 03:19:26 +02:00
Harsh Shandilya 125f725a03 fab: use AppCompatTextView for label
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-06-01 03:17:29 +02:00
Harsh Shandilya 3c84b48f08 fab: cleanup
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-06-01 03:16:32 +02:00
Jason A. Donenfeld 8c32c32c2b wg-quick: don't break push notifications
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-31 16:40:50 +02:00
Jason A. Donenfeld e664a05d4b KeyEncoding: more constant time
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-30 23:31:20 +02:00
Jason A. Donenfeld ba4672b422 Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-29 19:08:55 +02:00
Jason A. Donenfeld 09833a1ba5 FloatingActionButton: import cleaned up getbase code
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-29 19:03:47 +02:00
Jason A. Donenfeld ded0191aae SharedLibraryLoader: introduce to work around Samsung PackageManager bugs
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-29 05:09:37 +02:00
Jason A. Donenfeld 9245e9536a Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-27 19:00:38 +02:00
Jason A. Donenfeld 292df12175 Support always-on-vpn
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-27 18:57:52 +02:00
Jason A. Donenfeld f988306c17 libwg-go: Saner way to deal with sockets
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-27 18:17:55 +02:00
Jason A. Donenfeld 64ce6cd5a2 EditorFragment: show toast on creation too
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-27 04:08:23 +02:00
Jason A. Donenfeld 5476fc2228 Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-26 13:56:35 +02:00
Jason A. Donenfeld 7120ef9ffd libwg-go: try no stickiness and no roaming
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-26 03:03:15 +02:00
Jason A. Donenfeld 75f4478fb5 Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-24 19:26:48 +02:00
Jason A. Donenfeld 23c4174fcd libwg-go: reenable sticky sockets, just slightly less sticky
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-24 18:39:29 +02:00
Jason A. Donenfeld 5754df6b71 Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-23 17:12:18 +02:00
Jason A. Donenfeld 62dbeca732 libwg-go: use gopath
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-23 17:01:40 +02:00
Jason A. Donenfeld a533be82e8 libwg-go: No sticky sockets with VPNService.java
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-22 23:28:54 +02:00
Jason A. Donenfeld 52d90724bc Fix hang and version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-21 14:17:34 +02:00
Jason A. Donenfeld 4863bd647a Add stacktrace via SIGUSR2
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-21 14:13:55 +02:00
Jason A. Donenfeld cb62dc8fa2 Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-21 04:23:31 +02:00
Jason A. Donenfeld e3442cde56 libwg-go: better up/down sync
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-16 22:24:20 +02:00
Jason A. Donenfeld 694577b9b4 ExceptionLoggers: never have a null message
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-16 17:36:25 +02:00
Harsh Shandilya 9c3091456d android: Directly use views for snackbars
There should be no need to deference an extra variable.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-05-16 17:31:31 +02:00
Jason A. Donenfeld 515be5e453 libwg-go: more fixes
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-15 21:57:17 +02:00
Jason A. Donenfeld b89b9e89c2 build: version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-15 13:44:59 +02:00
Jason A. Donenfeld 9d20c378ba libwg-go: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-15 13:44:22 +02:00
Jason A. Donenfeld f661c67c89 tools: move wg-quick to main wireguard repo
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-14 18:25:42 +02:00
Jason A. Donenfeld e1ac4247ff libwg-go: make changes for recent go code
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-14 17:10:59 +02:00
Jason A. Donenfeld 34422e57a9 build: another bump for mistake
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-10 17:14:48 +02:00
Jason A. Donenfeld 088ff2dbda build: version bump and fix disaster
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-10 16:18:34 +02:00
Jason A. Donenfeld 2853515e8f build: version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-09 18:49:03 +02:00
Jason A. Donenfeld 95dbb14cb5 theme: revert to old color scheme
Noble effort, but ultimately ugly.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-09 18:38:13 +02:00
Harsh Shandilya 0b9bcf0f9e global: Cleanup line lengths and misc lint warnings
I know we decided to ditch the idea of shutting up "Exception
thrown with empty param" warnings but this pesters me too
much and we can instead just treat this as a weird future proofing
thing if and when we end up needing the exception messages.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-05-09 18:16:14 +02:00
Harsh Shandilya e2ab2210cd MainActivity: Nip out as early as possible when moving to same fragment
Save the useless logging and fragment manager object creation.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-05-09 18:16:09 +02:00
Jason A. Donenfeld 332c35747e libwg-go: new timer system upstream
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-09 17:38:27 +02:00
Jason A. Donenfeld ebe3297c83 libwg-go: ensure local Go instance is patched
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-09 17:33:36 +02:00
Samuel Holland 7f6c861fd6 mipmap: Fix formatting of launcher icon XML
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-05-05 10:11:35 -05:00
Harsh Shandilya 58b9a88bcb styles: Fixup CAB background color
Long pressing any list item entry would cause the action bar to
use the dark color from the parent theme -- fix that.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-05-05 10:11:20 -05:00
Harsh Shandilya e4eac7a3cf drawables: Introduce material iconography
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-05-05 10:11:14 -05:00
Harsh Shandilya 55ec3046d1 styles: Propagate WireGuard blue in UI
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-05-05 10:08:49 -05:00
Harsh Shandilya 6bd4f7495d styles: Propagate WireGuard red in UI
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-05-05 10:08:24 -05:00
Harsh Shandilya fd571c53ce TunnelEditor: Add toast messages to success events
Letting the user know that the operation went successfully
via visual cues is a nice UX touch.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-05-05 10:08:14 -05:00
Jason A. Donenfeld 5ed36d7346 wireguard-go: bump submodule
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-05 06:09:45 +02:00
Harsh Shandilya 37413f2fb4 TunnelEditor: Remove unused parameter
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-05-03 23:49:14 -05:00
Harsh Shandilya 59aa3035a8 ui: Use a proper CardView based layout
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-05-03 23:45:03 -05:00
Jason A. Donenfeld 46b374cf25 tools: include libmnl paths after system paths for ndk 17
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-03 19:15:09 -05:00
Jason A. Donenfeld b276833b33 config: loosen parser to match reality
Mid-line comments, mixed case.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-03 19:15:09 -05:00
Jason A. Donenfeld f77eac6796 global: fix up copyrights
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-03 19:15:09 -05:00
Samuel Holland e8d8d5dc29 Keypair: Minimize the scope of warning suppression
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-05-02 10:31:25 -05:00
Samuel Holland 3e8d457501 KeyEncoding: Address lints/warnings and match line length
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-05-02 10:31:25 -05:00
Samuel Holland aa92c4a9d5 global: Add or update copyright headers in Java code
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-05-02 10:31:25 -05:00
Harsh Shandilya 24572aa861 global: Some more lint cleanup
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-05-02 17:14:35 +02:00
Jason A. Donenfeld cb6681b15a drawable: add adaptive icon
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-02 07:19:05 +02:00
Jason A. Donenfeld a46b2eb9e5 libwg-go: avoid phony target and update go
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-02 06:02:15 +02:00
Harsh Shandilya a77ff1627d wg-build: Update gradle build files
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-05-02 03:40:02 +02:00
Harsh Shandilya 96ebf4cd51 libwg-go: Ignore go{path,root}
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-05-02 03:40:02 +02:00
Samuel Holland 691d8a34a0 project: Import select Android Studio configuration files
Having a consistent set of code style and inspection rules makes it
easier for contributors to match the existing code.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-05-01 16:31:21 -05:00
Jason A. Donenfeld 92fc1dbac8 libwg-go: do not deadlock on Close
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-05-01 17:48:59 +02:00
Jason A. Donenfeld 997138cd22 Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-30 23:11:32 +02:00
Jason A. Donenfeld ba1b6c7095 ZipExporterPreference: account for directory already existing
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-30 19:55:06 +02:00
Samuel Holland 843003f436 global: Clean up Java
Address Java and Android lints.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-04-30 11:50:21 -05:00
Samuel Holland 8e4fb91a28 global: Clean up XML
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-04-30 11:39:23 -05:00
Samuel Holland 7eedf08d4b global: Automatic code formatting
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-04-30 11:39:12 -05:00
Samuel Holland e2636320b7 app: Sort dependencies
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-04-30 11:38:15 -05:00
Samuel Holland a481aa244c project: Update gradle files
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-04-30 11:38:15 -05:00
Jason A. Donenfeld 6ce739f01f libwg-go: use system Go when possible
We're still maybe curlzipping and using a binary distribution of Go, but
at least this is only the case on machines that don't have go.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-30 18:19:37 +02:00
Jason A. Donenfeld 05b4e395a9 Tunnel importer: stricter file filters
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-30 17:37:34 +02:00
Jason A. Donenfeld 65ca5979d2 proguard: enable
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-30 16:57:57 +02:00
Jason A. Donenfeld 3c84db7788 Preferences: use v14 material style
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-30 15:35:21 +02:00
Jason A. Donenfeld a47ddf57d1 ZipExporterPreference: requireNonNull is redundant
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-30 15:12:49 +02:00
Harsh Shandilya f9d68185e2 wg: Collapse fab when pressing back before exiting
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-04-30 17:33:24 +05:30
Harsh Shandilya f1fa46829d SettingsActivity: Migrate permissions check to AppCompat
Pretty straightforward, I was clearly overthinking this.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-04-30 17:30:25 +05:30
Harsh Shandilya a6e530049c ZipExporterPreference: Correctly get preference activity
In AppCompat based preferences, this#getContext returns an
object of android.view.ContextThemeWrapper class from where
we can safely extract a reference to our parent activity.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-04-30 17:30:25 +05:30
Harsh Shandilya 77c0d4dfa6 TunnelListFragment: Use Collections methods in place of Arrays
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-04-30 17:30:25 +05:30
Harsh Shandilya 7e415a62c7 wg: Break out crossport dependency
Replace all crossport uses with upstream design
support library components.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-04-30 17:30:25 +05:30
Harsh Shandilya 431b75be15 wg-build: Upgrade databinding library to 3.1.2
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-04-30 17:30:24 +05:30
Harsh Shandilya fe4cc22ca0 SettingsActivity: Gracefully exit when options menu home is pressed
This is an activity, so it does not join the fragment backstack, but
instead piles on top

SettingsActivity
| -> MainActivity
| -> EditorFragment
| -> DetailFragment
| -> ListFragment

Without overriding the back button in the toolbar, it simply
kills the entire state on MainActivity and causes it to reload.
By calling finish() on the activity when home is pressed from the
item menu we can silently make it die without affecting any underlying
states held by MainActivity and instead return to the exact fragment
we launched settings from.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-04-30 17:30:24 +05:30
Harsh Shandilya 4fc1e61a83 SettingsActivity: Define preferenceTheme for AppCompat
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-04-30 17:30:24 +05:30
Harsh Shandilya e7e571a301 wg: Migrate menu visibility to AppCompat
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-04-30 17:30:24 +05:30
Harsh Shandilya 425d194e4f wg: Add and use dummy AppTheme
Preparation for when the app will start carrying
colors reflecting the WireGuard brand.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-04-30 17:30:24 +05:30
Harsh Shandilya 4ec0b3a908 Prefer AppCompat classes
AppCompat is the preferred way to go for any app targetting
a wider range of SDKs.

Replace all activities and fragments with their AppCompat
variants and fixup method calls to use support variants.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-04-30 17:30:24 +05:30
Harsh Shandilya af57824c14 wireguard: Extract dependency versions to ext struct
Maintain common versions in a single place

Also upgraded the support library to 27.1.1 and
databinding library to 3.1.1.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-04-30 17:30:24 +05:30
Jason A. Donenfeld 596904977a TunnelDetailFragment: rewrite and simplify
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-30 05:29:54 +02:00
Jason A. Donenfeld 73b0c4ea81 TunnelEditorFragment: rewrite and simplify
This should remove some null pointer dereferences and overall make the
thing more robust.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-30 05:29:54 +02:00
Jason A. Donenfeld 622f41f11f Allow exporting to zip file
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-29 07:53:56 +02:00
Jason A. Donenfeld f4e462fabd Allow importing from zip file
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-28 21:55:42 +02:00
Harsh Shandilya 217ab5e17f config: Minor cleanup
- Stop implicitly assuming locales in String.format
- Cleanup method visibilities
- Improve uses of Integer methods
- Remove unused getToken method

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-04-28 06:07:48 +02:00
Harsh Shandilya ba862b166b Quick cleanup across the board
- Clean up imports
- Adjust method visibility
- Drop in NonNull annotations where needed
- Prevent potential NPEs from nulled getActivity calls
- Remove unused methods

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2018-04-28 06:07:48 +02:00
Jason A. Donenfeld 592c5cbbd6 Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-28 04:56:12 +02:00
Jason A. Donenfeld 63071f57b7 Use validation instead of two-way binding
This is insane, but it appears to be working. We essentially store
things in a separate class for editing, and then commit it back at a
given time.

This business with onViewStateRestored in both TunnelEditorFragment and
in TunnelDetailFragment is buggy and likely wrong.

In general TunnelEditorFragment should probably be rewritten. The
relationship with the changed name is not clear.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-28 04:51:43 +02:00
Jason A. Donenfeld 693228985d Do not do DNS lookups for IPs
This involves reflection, which is a bummer, but it's better than doing
unnecessary DNS lookups.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-27 18:34:52 +02:00
Jason A. Donenfeld 9c6f9135e9 Add build instructions
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-27 16:45:16 +02:00
Jason A. Donenfeld 9ee976823d Throw IllegalArgumentExceptions when arguments are bad
This will make the two way data binding crash more, but it will improve
the robustness of the config file parser, which deals with exceptions
gracefully, and when we move to one way data binding, it will help with
that too.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-27 05:43:07 +02:00
Jason A. Donenfeld 254cc4cc87 Latest go changes
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-27 05:43:07 +02:00
Jason A. Donenfeld 31101f2418 WgQuickBackend: always create configuration file
It might be removed on an update.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-26 19:42:55 +02:00
Jason A. Donenfeld 8d2510ae9e Manifest: disable always-on VPN
We don't actually comprehend how this works yet, so disable it. But
we'll need to add support for this at some point.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-26 02:25:55 +02:00
Jason A. Donenfeld 532edf774a GoBackend: bring down tunnels when revoked or disconnected
This synchronizes the OS's connection state with ours, such as when the
user disconnects using the system UI.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-25 18:27:18 +02:00
Jason A. Donenfeld 86ffb24748 Use variable map instead of shell switch
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-25 14:43:46 +02:00
Jason A. Donenfeld 2c9e11f4f2 Curve25519: fix up spacing
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-25 14:36:51 +02:00
Jason A. Donenfeld e6838f9cb0 Use binary distro of Golang
This is a bummer, but Gradle already specifies tons of specific versions
of various binary components, so this is not materially different than
the rest of how this whole thing works.

It also allows us to specify the Go version that will actually build a
working binary of wireguard-go, since all of the Go bugs mean not every
version works equally. We do *not* want to use whatever version a distro
happens to be shipping.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-24 15:34:13 +02:00
Jason A. Donenfeld 83b30bed7b Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-23 17:04:17 +02:00
Jason A. Donenfeld 88cf839c90 Update application state based on wg-quick
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-23 17:04:17 +02:00
Jason A. Donenfeld a1c6f4b3b7 Version bump
Due to https://github.com/golang/go/issues/24950

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-19 18:55:25 +02:00
Jason A. Donenfeld 32fcb3fccf Work around go fd closing limitation and version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-19 17:11:02 +02:00
Jason A. Donenfeld e7c6e487ea Version bump for go race condition
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-18 21:33:18 +02:00
Jason A. Donenfeld 80f22e6c3d Determine MTU automatically
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-18 16:44:05 +02:00
Jason A. Donenfeld ed42e30069 Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-18 09:56:06 +02:00
Jason A. Donenfeld dc1b808f8e Update dependencies
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-18 09:51:55 +02:00
Jason A. Donenfeld 53d29b312f More javafication
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-18 05:28:31 +02:00
Jason A. Donenfeld 69f1a35a3f Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-17 06:02:03 +02:00
Jason A. Donenfeld 140fb395dc GoBackend: default MTU is 1280
This sucks, but it works with mobile networks. Later we can do something
sophisticated like we do with wg-quick.c, but not now.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-17 05:59:23 +02:00
Jason A. Donenfeld b5360871e8 Remove sloppy java with enterprise java horrors
Since the amount of mind numbing boiler plate has been increased, this
must be the proper way to do things.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-17 05:27:05 +02:00
Jason A. Donenfeld e40c579b0e global: update various upstreams
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-17 02:25:35 +02:00
Aurélien Chabot 4c9143c835 GoBackend: Handle vpn service expiration
After a timeout the android system is destroying the vpn service when it
is not used. By using a completable future we can wait for the service
to be relaunch on demand.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-17 02:15:24 +02:00
Aurélien Chabot 74eae55c87 Config: Handle multiple address or dns in config file
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-17 02:15:24 +02:00
Aurélien Chabot 44698bb000 GoBackend: Add support for multiple address and dns as a comma separated list
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-17 02:15:24 +02:00
Aurélien Chabot 175f7e16dd GoBackend: parse allowed ips
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-17 02:15:24 +02:00
Aurélien Chabot c6d311923a GoBackend: Parse the dns address
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-17 02:15:24 +02:00
Aurélien Chabot 6878aba911 GoBackend: IPv6 handling
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-17 02:15:24 +02:00
Aurélien Chabot d97312b96a GoBackend: Resolve endpoint before passing it to the go lib
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-17 02:15:24 +02:00
Aurélien Chabot 9dfab4d60f GoBackend: Use the android VpnService to encapsulate the go backend
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-04-17 02:15:24 +02:00
Jason A. Donenfeld 19aec7c5c6 GoBackend: support NO_PI mode
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-02-28 19:59:50 +01:00
Jason A. Donenfeld f2113f80db Update submodules
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-02-20 17:01:54 +01:00
Jason A. Donenfeld 0ea6f73332 GoBackend: integrate into app
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-02-17 21:14:09 +01:00
Jason A. Donenfeld b923f7bc57 wg: bump commit
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-02-17 21:14:09 +01:00
Jason A. Donenfeld d1c863b16e KeyEncoding: add constant time hex implementation
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-02-13 19:47:31 +01:00
Samuel Holland b22e2b259b manifest: Add permission to read external storage
This fixes support for file managers that don't proxy the file access
from the file selection dialog through a content provider, and just
return a raw file:// URL. In this case, resolver.openInputStream() tries
to open the file directly, and fails with "Permission denied".

Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-02-03 12:47:14 -06:00
Jason A. Donenfeld a66348c315 Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-01-18 23:17:29 +01:00
Samuel Holland c683d23125 FileConfigStore: Warn for deletion failure in exception path
There's nothing we can do about it at this point; we're already rolling
back changes.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-18 04:12:54 -06:00
Samuel Holland 23535c0577 WgQuickBackend: Always pass the full path to wg-quick
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-18 04:10:58 -06:00
Samuel Holland 8dde6c3c0f fragments: Be extra paranoid about the binding getting destroyed
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-18 04:10:58 -06:00
Samuel Holland 54f201174d TunnelManager: Use constants directly where appropriate
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-17 14:35:39 -06:00
Samuel Holland fb3138bdda Peer: Add missing @Override
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-17 14:35:39 -06:00
Samuel Holland f63aeea6b8 WgQuickBackend: Clean up unused fields and imports
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-17 14:35:39 -06:00
Samuel Holland 09c207b8a3 ToolsInstaller: Remove double-checked locking
It can't work and may be crashing the runtime.

Use a lock object to avoid exposing the synchronization in the class's
interface.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-17 14:35:39 -06:00
Samuel Holland d56eda2fd6 RootShell: Use a lock object instead of sync methods
This avoids exposing the synchronization implementation details
in the class's interface.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-17 14:35:14 -06:00
Jason A. Donenfeld 75aeec035c Build bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-01-10 23:52:02 +01:00
Jason A. Donenfeld c1cc2774be Manifest: show back arrow on sub activities
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-01-10 23:52:02 +01:00
Jason A. Donenfeld 7e06768f75 ToolsInstaller: symlink tools always
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-01-10 23:47:13 +01:00
Jason A. Donenfeld 7a618c1463 FileConfigStore: cleanup on rename problem
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-01-10 23:26:12 +01:00
Samuel Holland f8ee7dcce9 QuickTileService: Fix crash opening activity
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-10 11:13:16 -06:00
Samuel Holland 30901a6152 TunnelController: Use helper function to unwrap the Throwable
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-10 00:03:45 -06:00
Samuel Holland 7b9c1a536c model: Use ConfigStore.rename() to avoid recreating tunnels
Rename all of the functions to be in line with setConfig/setState

Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-10 00:03:03 -06:00
Samuel Holland 951afaa9b2 ConfigStore: Add a rename method and implement it
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-10 00:01:52 -06:00
Samuel Holland 5ce7eba2bf FileConfigStore: Simplify error handling
Signed-off-by: Samuel Holland <samuel@sholland.org>
2018-01-09 23:57:15 -06:00
Jason A. Donenfeld dfa4a2eb9d WgQuickBackend: properly report exception so alert shows
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-01-10 03:16:42 +01:00
Jason A. Donenfeld df3062c7ad Tunnel: ifname has max len 15
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-01-10 02:49:06 +01:00
Jason A. Donenfeld b3e928c1bf tools: error if setconf fails
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-01-10 02:48:05 +01:00
Jason A. Donenfeld 01faa9b358 tools: ifname has max len 15
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-01-10 02:38:29 +01:00
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 42a4579451 project: Ignore native build artifacts
Signed-off-by: Samuel Holland <samuel@sholland.org>
2017-12-26 14:06:10 -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
Samuel Holland cd105312ca tools: Remove stale entry from .gitmodules
Signed-off-by: Samuel Holland <samuel@sholland.org>
2017-12-26 13:58:05 -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 e418c5d3b4 README: update with links
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-28 16:31:13 +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 982387b4e4 Build: update gradle
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-27 18:40:51 +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 2ec43f38a3 project: License under GPL-2.0+
This allows using Apache 2.0-licensed libraries, because the Apache 2.0
license is only compatible with version 3 of the GPL.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2017-11-25 22:12:10 -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
Jason A. Donenfeld 69d4fe9a81 cli: move to android_kernel_wireguard
These tools are now part of the ROM builder's toolkit at:
https://git.zx2c4.com/android_kernel_wireguard/about/

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-25 02:11:55 +01:00
Jason A. Donenfeld bdfb319854 Verison bump tools
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-16 22:15:05 +01: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
Jason A. Donenfeld 157f754510 cli: add wg(8) build script
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-11-01 18:23:38 +01: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 f8b7030e22 project: Add gradle wrapper
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-28 23:11:24 -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
Jason A. Donenfeld b8cb52ed4b project: Skeleton with license and readme
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-31 03:00:41 +02:00
Jason A. Donenfeld 506d871013 cli: only call DNS if there is DNS
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-31 22:26:00 +02:00
Jason A. Donenfeld b2f4a755a0 cli: add multi-DNS to wg-quick
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-31 05:15:05 +02:00
Jason A. Donenfeld df4fc98493 cli: import from contrib/examples/android
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-31 03:02:26 +02:00
Samuel Holland e85142dbfc git: Initialize repository
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-28 22:59:47 -05:00
232 changed files with 7485 additions and 4315 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
[submodule "tunnel/tools/amneziawg-tools"]
path = tunnel/tools/amneziawg-tools
url = https://github.com/amnezia-vpn/amneziawg-tools
[submodule "tunnel/tools/wireguard-tools"]
path = tunnel/tools/wireguard-tools
url = https://git.zx2c4.com/wireguard-tools
[submodule "tunnel/tools/elf-cleaner"]
path = tunnel/tools/elf-cleaner
url = https://github.com/termux/termux-elf-cleaner
+474
View File
@@ -0,0 +1,474 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<option name="AUTODETECT_INDENTS" value="false" />
<option name="LINE_SEPARATOR" value="&#10;" />
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
<option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
<value />
</option>
<option name="IMPORT_LAYOUT_TABLE">
<value>
<package name="android" withSubpackages="true" static="false" />
<emptyLine />
<package name="com" withSubpackages="true" static="false" />
<emptyLine />
<package name="junit" withSubpackages="true" static="false" />
<emptyLine />
<package name="net" withSubpackages="true" static="false" />
<emptyLine />
<package name="org" withSubpackages="true" static="false" />
<emptyLine />
<package name="java" withSubpackages="true" static="false" />
<emptyLine />
<package name="javax" withSubpackages="true" static="false" />
<emptyLine />
<package name="" withSubpackages="true" static="false" />
<emptyLine />
<package name="" withSubpackages="true" static="true" />
<emptyLine />
</value>
</option>
<JavaCodeStyleSettings>
<option name="GENERATE_FINAL_LOCALS" value="true" />
<option name="GENERATE_FINAL_PARAMETERS" value="true" />
<option name="INSERT_INNER_CLASS_IMPORTS" value="true" />
<option name="IMPORT_LAYOUT_TABLE">
<value>
<package name="android" withSubpackages="true" static="false" />
<emptyLine />
<package name="com" withSubpackages="true" static="false" />
<emptyLine />
<package name="junit" withSubpackages="true" static="false" />
<emptyLine />
<package name="net" withSubpackages="true" static="false" />
<emptyLine />
<package name="org" withSubpackages="true" static="false" />
<emptyLine />
<package name="java" withSubpackages="true" static="false" />
<emptyLine />
<package name="javax" withSubpackages="true" static="false" />
<emptyLine />
<package name="" withSubpackages="true" static="false" />
<emptyLine />
<package name="" withSubpackages="true" static="true" />
<emptyLine />
</value>
</option>
</JavaCodeStyleSettings>
<JetCodeStyleSettings>
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
<value>
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
</value>
</option>
<option name="NAME_COUNT_TO_USE_STAR_IMPORT" value="10" />
<option name="NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS" value="10" />
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</JetCodeStyleSettings>
<codeStyleSettings language="JAVA">
<option name="METHOD_ANNOTATION_WRAP" value="0" />
<option name="FIELD_ANNOTATION_WRAP" value="0" />
<arrangement>
<groups />
<rules>
<section>
<rule>
<match>
<AND>
<FIELD>true</FIELD>
<FINAL>true</FINAL>
<PUBLIC>true</PUBLIC>
<STATIC>true</STATIC>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<FIELD>true</FIELD>
<FINAL>true</FINAL>
<PROTECTED>true</PROTECTED>
<STATIC>true</STATIC>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<FIELD>true</FIELD>
<FINAL>true</FINAL>
<PACKAGE_PRIVATE>true</PACKAGE_PRIVATE>
<STATIC>true</STATIC>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<FIELD>true</FIELD>
<FINAL>true</FINAL>
<PRIVATE>true</PRIVATE>
<STATIC>true</STATIC>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<FIELD>true</FIELD>
<PUBLIC>true</PUBLIC>
<STATIC>true</STATIC>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<FIELD>true</FIELD>
<PROTECTED>true</PROTECTED>
<STATIC>true</STATIC>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<FIELD>true</FIELD>
<PACKAGE_PRIVATE>true</PACKAGE_PRIVATE>
<STATIC>true</STATIC>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<FIELD>true</FIELD>
<PRIVATE>true</PRIVATE>
<STATIC>true</STATIC>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<INITIALIZER_BLOCK>true</INITIALIZER_BLOCK>
<STATIC>true</STATIC>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<FIELD>true</FIELD>
<FINAL>true</FINAL>
<PUBLIC>true</PUBLIC>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<FIELD>true</FIELD>
<FINAL>true</FINAL>
<PROTECTED>true</PROTECTED>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<FIELD>true</FIELD>
<FINAL>true</FINAL>
<PACKAGE_PRIVATE>true</PACKAGE_PRIVATE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<FIELD>true</FIELD>
<FINAL>true</FINAL>
<PRIVATE>true</PRIVATE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<FIELD>true</FIELD>
<PUBLIC>true</PUBLIC>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<FIELD>true</FIELD>
<PROTECTED>true</PROTECTED>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<FIELD>true</FIELD>
<PACKAGE_PRIVATE>true</PACKAGE_PRIVATE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<FIELD>true</FIELD>
<PRIVATE>true</PRIVATE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<FIELD>true</FIELD>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<INITIALIZER_BLOCK>true</INITIALIZER_BLOCK>
</match>
</rule>
</section>
<section>
<rule>
<match>
<CONSTRUCTOR>true</CONSTRUCTOR>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<METHOD>true</METHOD>
<STATIC>true</STATIC>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<METHOD>true</METHOD>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<ENUM>true</ENUM>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<INTERFACE>true</INTERFACE>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<CLASS>true</CLASS>
<STATIC>true</STATIC>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<CLASS>true</CLASS>
</match>
<order>BY_NAME</order>
</rule>
</section>
</rules>
</arrangement>
</codeStyleSettings>
<codeStyleSettings language="XML">
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions>
<arrangement>
<rules>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:android</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:id</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>style</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
<order>ANDROID_ATTRIBUTE_ORDER</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>.*</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
</rules>
</arrangement>
</codeStyleSettings>
<codeStyleSettings language="kotlin">
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
<option name="RIGHT_MARGIN" value="160" />
</codeStyleSettings>
</code_scheme>
</component>
+5
View File
@@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
</state>
</component>
+6
View File
@@ -0,0 +1,6 @@
<component name="CopyrightManager">
<copyright>
<option name="notice" value="Copyright © 2017-&amp;#36;today.year WireGuard LLC. All Rights Reserved.&#10;SPDX-License-Identifier: Apache-2.0" />
<option name="myName" value="Default" />
</copyright>
</component>
+3
View File
@@ -0,0 +1,3 @@
<component name="CopyrightManager">
<settings default="Default" />
</component>
+527
View File
@@ -0,0 +1,527 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0" is_locked="false">
<option name="myName" value="Default" />
<inspection_tool class="AbstractClassNamingConvention" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="AbstractClassWithoutAbstractMethods" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AccessToNonThreadSafeStaticFieldFromInstance" enabled="true" level="WARNING" enabled_by_default="true">
<option name="nonThreadSafeClasses">
<value />
</option>
<option name="nonThreadSafeTypes" value="" />
</inspection_tool>
<inspection_tool class="AndroidLintIconExpectedSize" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AndroidLintNegativeMargin" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AndroidLintTypographyQuotes" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AnnotationNamingConvention" enabled="false" level="WARNING" enabled_by_default="false">
<option name="m_regex" value="[A-Z][A-Za-z\d]*" />
<option name="m_minLength" value="8" />
<option name="m_maxLength" value="64" />
</inspection_tool>
<inspection_tool class="AnonymousClassVariableHidesContainingMethodVariable" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AnonymousInnerClass" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AnonymousInnerClassMayBeStatic" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ApiName" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="ApiNamespace" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="ApiParameter" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="ArrayEquality" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ArrayIssues" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AssignmentOrReturnOfFieldWithMutableTypeMerged" />
<inspection_tool class="AssignmentToCatchBlockParameter" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AssignmentToCollectionFieldFromParameter" enabled="false" level="WARNING" enabled_by_default="false">
<option name="ignorePrivateMethods" value="false" />
</inspection_tool>
<inspection_tool class="AssignmentToDateFieldFromParameter" enabled="false" level="WARNING" enabled_by_default="false">
<option name="ignorePrivateMethods" value="true" />
</inspection_tool>
<inspection_tool class="AssignmentToForLoopParameter" enabled="true" level="WARNING" enabled_by_default="true">
<option name="m_checkForeachParameters" value="false" />
</inspection_tool>
<inspection_tool class="AssignmentToLambdaParameter" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AssignmentToSuperclassField" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AssignmentUsedAsCondition" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AutoCloseableResource" enabled="true" level="WARNING" enabled_by_default="true">
<option name="METHOD_MATCHER_CONFIG" value="java.util.Formatter,format,java.io.Writer,append,com.google.common.base.Preconditions,checkNotNull,org.hibernate.Session,close,java.io.PrintWriter,printf,java.util.HashMap,put,java.util.Map,put" />
</inspection_tool>
<inspection_tool class="BadExceptionCaught" enabled="true" level="WARNING" enabled_by_default="true">
<option name="exceptionsString" value="" />
<option name="exceptions">
<value />
</option>
</inspection_tool>
<inspection_tool class="BadOddness" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="BooleanExpressionMayBeConditional" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="BooleanParameter" enabled="true" level="WARNING" enabled_by_default="true">
<option name="onlyReportMultiple" value="true" />
</inspection_tool>
<inspection_tool class="CallToSimpleGetterInClass" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoreGetterCallsOnOtherObjects" value="false" />
<option name="onlyReportPrivateGetter" value="false" />
</inspection_tool>
<inspection_tool class="CallToStringConcatCanBeReplacedByOperator" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="CannotResolve" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="CastConflictsWithInstanceof" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="CatchMayIgnoreException" enabled="true" level="WARNING" enabled_by_default="true">
<option name="m_ignoreCatchBlocksWithComments" value="false" />
</inspection_tool>
<inspection_tool class="ChainedEquality" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ClassInitializer" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ClassNameDiffersFromFileName" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ClassNamingConvention" enabled="false" level="WARNING" enabled_by_default="false">
<option name="m_regex" value="[A-Z][A-Za-z\d]*" />
<option name="m_minLength" value="8" />
<option name="m_maxLength" value="64" />
</inspection_tool>
<inspection_tool class="ClassReferencesSubclass" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ClassWithOnlyPrivateConstructors" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ComparableImplementedButEqualsNotOverridden" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="CompareToUsesNonFinalVariable" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ConditionalExpression" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="ConditionalExpressionWithIdenticalBranches" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ConstExpressionRequired" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="ConstantNamingConvention" enabled="true" level="WARNING" enabled_by_default="true">
<option name="onlyCheckImmutables" value="false" />
<option name="m_regex" value="[A-Z][A-Z_\d]*" />
<option name="m_minLength" value="0" />
<option name="m_maxLength" value="0" />
</inspection_tool>
<inspection_tool class="ConstantValueVariableUse" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ConstructionIsNotAllowed" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="Constructor" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="Convert2streamapi" enabled="true" level="WARNING" enabled_by_default="true">
<option name="REPLACE_TRIVIAL_FOREACH" value="true" />
<option name="SUGGEST_FOREACH" value="true" />
</inspection_tool>
<inspection_tool class="ConvertAnnotations" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="CovariantEquals" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="DeclareCollectionAsInterface" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoreLocalVariables" value="false" />
<option name="ignorePrivateMethodsAndFields" value="false" />
</inspection_tool>
<inspection_tool class="DefaultNotLastCaseInSwitch" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="DerivedFunctionsReturnTypeMismatch" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="DeserializableClassInSecureContext" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="DoubleBraceInitialization" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="DoubleCheckedLocking" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoreOnVolatileVariables" value="false" />
</inspection_tool>
<inspection_tool class="DoubleLiteralMayBeFloatLiteral" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="DuplicateAlternationBranch" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="DuplicateBooleanBranch" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="DuplicateDeclarations" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="DynamicRegexReplaceableByCompiledPattern" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ElementOnlyUsedFromTestCode" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="EmptyClass" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignorableAnnotations">
<value />
</option>
<option name="ignoreClassWithParameterization" value="true" />
<option name="ignoreThrowables" value="true" />
<option name="commentsAreContent" value="true" />
</inspection_tool>
<inspection_tool class="EmptySynchronizedStatement" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="EnumSwitchStatementWhichMissesCases" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoreSwitchStatementsWithDefault" value="false" />
</inspection_tool>
<inspection_tool class="EnumeratedClassNamingConvention" enabled="false" level="WARNING" enabled_by_default="false">
<option name="m_regex" value="[A-Z][A-Za-z\d]*" />
<option name="m_minLength" value="8" />
<option name="m_maxLength" value="64" />
</inspection_tool>
<inspection_tool class="EnumeratedConstantNamingConvention" enabled="false" level="WARNING" enabled_by_default="false">
<option name="m_regex" value="[A-Z][A-Z_\d]*" />
<option name="m_minLength" value="5" />
<option name="m_maxLength" value="32" />
</inspection_tool>
<inspection_tool class="EnumerationCanBeIteration" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="EqualityOperatorComparesObjects" enabled="true" level="INFORMATION" enabled_by_default="true" />
<inspection_tool class="EqualsAndHashcode" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="EqualsCalledOnEnumConstant" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="EqualsUsesNonFinalVariable" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="EscapedMetaCharacter" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="ExceptionFromCatchWhichDoesntWrap" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoreGetMessage" value="false" />
<option name="ignoreCantWrap" value="false" />
</inspection_tool>
<inspection_tool class="ExtendsThrowable" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ExtendsUtilityClass" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="FallthruInSwitchStatement" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="FieldAccessedSynchronizedAndUnsynchronized" enabled="true" level="WARNING" enabled_by_default="true">
<option name="countGettersAndSetters" value="false" />
</inspection_tool>
<inspection_tool class="FieldMayBeFinal" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="FieldMayBeStatic" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="FieldMustBeInitialized" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="FinalMethodInFinalClass" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="FloatingPointEquality" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ForLoopReplaceableByWhile" enabled="true" level="WARNING" enabled_by_default="true">
<option name="m_ignoreLoopsWithoutConditions" value="false" />
</inspection_tool>
<inspection_tool class="FrequentlyUsedInheritorInspection" enabled="false" level="INFORMATION" enabled_by_default="false" />
<inspection_tool class="FullJavaName" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="FullMethodName" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="FunctionParameterCountMismatch" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="FuseStreamOperations" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="GrFieldAlreadyDefined" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="GroovyAnnotationNamingConvention" enabled="false" level="WARNING" enabled_by_default="false">
<option name="m_regex" value="[A-Z][A-Za-z\d]*" />
<option name="m_minLength" value="8" />
<option name="m_maxLength" value="64" />
</inspection_tool>
<inspection_tool class="GroovyClassNamingConvention" enabled="false" level="WARNING" enabled_by_default="false">
<option name="m_regex" value="[A-Z][A-Za-z\d]*" />
<option name="m_minLength" value="8" />
<option name="m_maxLength" value="64" />
</inspection_tool>
<inspection_tool class="GroovyEnumerationNamingConvention" enabled="false" level="WARNING" enabled_by_default="false">
<option name="m_regex" value="[A-Z][A-Za-z\d]*" />
<option name="m_minLength" value="8" />
<option name="m_maxLength" value="64" />
</inspection_tool>
<inspection_tool class="GroovyInterfaceNamingConvention" enabled="false" level="WARNING" enabled_by_default="false">
<option name="m_regex" value="[A-Z][A-Za-z\d]*" />
<option name="m_minLength" value="8" />
<option name="m_maxLength" value="64" />
</inspection_tool>
<inspection_tool class="HashCodeUsesNonFinalVariable" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="HtmlTagCanBeJavadocTag" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="IOResource" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoredTypesString" value="java.io.ByteArrayOutputStream,java.io.ByteArrayInputStream,java.io.StringBufferInputStream,java.io.CharArrayWriter,java.io.CharArrayReader,java.io.StringWriter,java.io.StringReader" />
<option name="insideTryAllowed" value="false" />
</inspection_tool>
<inspection_tool class="IfMayBeConditional" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="IfStatementWithIdenticalBranches" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="IgnoreResultOfCall" enabled="true" level="WARNING" enabled_by_default="true">
<option name="m_reportAllNonLibraryCalls" value="false" />
<option name="callCheckString" value="java.io.File,.*,java.io.InputStream,read|skip|available|markSupported,java.io.Reader,read|skip|ready|markSupported,java.lang.Boolean,.*,java.lang.Byte,.*,java.lang.Character,.*,java.lang.Double,.*,java.lang.Float,.*,java.lang.Integer,.*,java.lang.Long,.*,java.lang.Math,.*,java.lang.Object,equals|hashCode|toString,java.lang.Short,.*,java.lang.StrictMath,.*,java.lang.String,.*,java.math.BigInteger,.*,java.math.BigDecimal,.*,java.net.InetAddress,.*,java.net.URI,.*,java.util.UUID,.*,java.util.regex.Matcher,pattern|toMatchResult|start|end|group|groupCount|matches|find|lookingAt|quoteReplacement|replaceAll|replaceFirst|regionStart|regionEnd|hasTransparantBounds|hasAnchoringBounds|hitEnd|requireEnd,java.util.regex.Pattern,.*,java.util.stream.BaseStream,.*" />
</inspection_tool>
<inspection_tool class="ImplicitSubclassInspection" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="IncompatibleTypes" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="InitializerIssues" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="InnerClassReferencedViaSubclass" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="InnerClassVariableHidesOuterClassVariable" enabled="true" level="WARNING" enabled_by_default="true">
<option name="m_ignoreInvisibleFields" value="true" />
</inspection_tool>
<inspection_tool class="InstanceMethodNamingConvention" enabled="false" level="WARNING" enabled_by_default="false">
<option name="m_regex" value="[a-z][A-Za-z\d]*" />
<option name="m_minLength" value="4" />
<option name="m_maxLength" value="32" />
</inspection_tool>
<inspection_tool class="InstanceVariableNamingConvention" enabled="false" level="WARNING" enabled_by_default="false">
<option name="m_regex" value="m_[a-z][A-Za-z\d]*" />
<option name="m_minLength" value="5" />
<option name="m_maxLength" value="32" />
</inspection_tool>
<inspection_tool class="InstanceofCatchParameter" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="InstanceofThis" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="InstantiationOfUtilityClass" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="IntLiteralMayBeLongLiteral" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="IntegerTypeRequired" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="InterfaceMayBeAnnotatedFunctional" enabled="true" level="INFORMATION" enabled_by_default="true" />
<inspection_tool class="InterfaceNamingConvention" enabled="false" level="WARNING" enabled_by_default="false">
<option name="m_regex" value="[A-Z][A-Za-z\d]*" />
<option name="m_minLength" value="8" />
<option name="m_maxLength" value="64" />
</inspection_tool>
<inspection_tool class="InvalidParameterAnnotations" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="IteratorNextDoesNotThrowNoSuchElementException" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="JUnit3MethodNamingConvention" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JUnit4MethodNamingConvention" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JUnitAbstractTestClassNamingConvention" enabled="false" level="WARNING" enabled_by_default="false">
<option name="m_regex" value="[A-Z][A-Za-z\d]*TestCase" />
<option name="m_minLength" value="12" />
<option name="m_maxLength" value="64" />
</inspection_tool>
<inspection_tool class="JUnitTestClassNamingConvention" enabled="false" level="WARNING" enabled_by_default="false">
<option name="m_regex" value="[A-Z][A-Za-z\d]*Test" />
<option name="m_minLength" value="8" />
<option name="m_maxLength" value="64" />
</inspection_tool>
<inspection_tool class="Java8ArraySetAll" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="Java9CollectionFactory" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JavaRequiresAutoModule" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JavadocHtmlLint" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="KeySetIterationMayUseEntrySet" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="LambdaCanBeMethodCall" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="LambdaParameterHidingMemberVariable" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="LengthOneStringsInConcatenation" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="LimitedScopeInnerClass" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ListIndexOfReplaceableByContains" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="LiteralAsArgToStringEquals" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="LocalCanBeFinal" enabled="true" level="WARNING" enabled_by_default="true">
<option name="REPORT_VARIABLES" value="true" />
<option name="REPORT_PARAMETERS" value="true" />
</inspection_tool>
<inspection_tool class="LocalVariableHidingMemberVariable" enabled="true" level="WARNING" enabled_by_default="true">
<option name="m_ignoreInvisibleFields" value="true" />
<option name="m_ignoreStaticMethods" value="true" />
</inspection_tool>
<inspection_tool class="LoopWithImplicitTerminationCondition" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="MagicNumber" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoreInitialCapacity" value="true" />
</inspection_tool>
<inspection_tool class="MapReplaceableByEnumMap" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="MemberVisibility" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="MemberVisibilityCanPrivate" enabled="true" level="INFO" enabled_by_default="true" />
<inspection_tool class="MethodMayBeStatic" enabled="true" level="WARNING" enabled_by_default="true">
<option name="m_onlyPrivateOrFinal" value="false" />
<option name="m_ignoreEmptyMethods" value="true" />
</inspection_tool>
<inspection_tool class="MethodMayBeSynchronized" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="MethodName" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="MethodOnlyUsedFromInnerClass" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoreMethodsAccessedFromAnonymousClass" value="false" />
<option name="ignoreStaticMethodsFromNonStaticInnerClass" value="false" />
<option name="onlyReportStaticMethods" value="false" />
</inspection_tool>
<inspection_tool class="MethodOverloadsParentMethod" enabled="true" level="WARNING" enabled_by_default="true">
<option name="reportIncompatibleParameters" value="true" />
</inspection_tool>
<inspection_tool class="MethodOverridesInaccessibleMethodOfSuper" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="MethodOverridesStaticMethod" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="MethodParameterType" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="MethodReturnType" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="MissingDeprecatedAnnotation" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="MissingOverrideAnnotation" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoreObjectMethods" value="false" />
<option name="ignoreAnonymousClassMethods" value="false" />
</inspection_tool>
<inspection_tool class="MissortedModifiers" enabled="true" level="WARNING" enabled_by_default="true">
<option name="m_requireAnnotationsFirst" value="true" />
</inspection_tool>
<inspection_tool class="MoveFieldAssignmentToInitializer" enabled="false" level="INFORMATION" enabled_by_default="false" />
<inspection_tool class="MultipleDeclaration" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoreForLoopDeclarations" value="true" />
</inspection_tool>
<inspection_tool class="MultipleTopLevelClassesInFile" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="MultipleVariablesInDeclaration" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="NamedResource" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="NativeMethodNamingConvention" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="NegatedConditional" enabled="true" level="WARNING" enabled_by_default="true">
<option name="m_ignoreNegatedNullComparison" value="true" />
</inspection_tool>
<inspection_tool class="NegatedConditionalExpression" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="NegatedEqualityExpression" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="NegatedIfElse" enabled="true" level="WARNING" enabled_by_default="true">
<option name="m_ignoreNegatedNullComparison" value="true" />
<option name="m_ignoreNegatedZeroComparison" value="false" />
</inspection_tool>
<inspection_tool class="NegativelyNamedBooleanVariable" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="NestedSynchronizedStatement" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="NewClassNamingConventionMerged" />
<inspection_tool class="NewExceptionWithoutArguments" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="NewGroovyClassNamingConventionMerged" />
<inspection_tool class="NewMethodNamingConventionMerged" />
<inspection_tool class="NoDefaultBaseConstructor" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="NonAsciiCharacters" enabled="true" level="WARNING" enabled_by_default="true">
<option name="CHECK_FOR_FILES_CONTAINING_BOM" value="true" />
</inspection_tool>
<inspection_tool class="NonExceptionNameEndsWithException" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="NonFinalFieldInEnum" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="NonFinalFieldOfException" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="NonFinalStaticVariableUsedInClassInitialization" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="NonFinalUtilityClass" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="NonProtectedConstructorInAbstractClass" enabled="true" level="WARNING" enabled_by_default="true">
<option name="m_ignoreNonPublicClasses" value="false" />
</inspection_tool>
<inspection_tool class="NonShortCircuitBoolean" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="NonSynchronizedMethodOverridesSynchronizedMethod" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="NonThreadSafeLazyInitialization" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="NoopMethodInAbstractClass" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="NotAssignable" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="NullThrown" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ObjectEquality" enabled="false" level="WARNING" enabled_by_default="false">
<option name="m_ignoreEnums" value="true" />
<option name="m_ignoreClassObjects" value="false" />
<option name="m_ignorePrivateConstructors" value="false" />
</inspection_tool>
<inspection_tool class="ObjectInstantiationInEqualsHashCode" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ObjectToString" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ObsoleteCollection" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoreRequiredObsoleteCollectionTypes" value="false" />
</inspection_tool>
<inspection_tool class="OctalEscape" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="OptionalContainsCollection" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="OverlyStrongTypeCast" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoreInMatchingInstanceof" value="true" />
</inspection_tool>
<inspection_tool class="OverriddenMethodCallDuringObjectConstruction" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="PackageInfoWithoutPackage" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="PointerTypeRequired" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="ProblematicVarargsMethodOverride" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ProtectedField" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ProtectedInnerClass" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoreEnums" value="false" />
<option name="ignoreInterfaces" value="false" />
</inspection_tool>
<inspection_tool class="ProtectedMemberInFinalClass" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="PublicConstructorInNonPublicClass" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="PublicField" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoreEnums" value="false" />
<option name="ignorableAnnotations">
<value />
</option>
</inspection_tool>
<inspection_tool class="PublicFieldAccessedInSynchronizedContext" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="RandomDoubleForRandomInteger" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="RedundantFieldInitialization" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="RedundantImplements" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoreSerializable" value="false" />
<option name="ignoreCloneable" value="false" />
</inspection_tool>
<inspection_tool class="RedundantMethodOverride" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="RedundantThrowsDeclaration" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="RepeatedSpace" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ReplaceAssignmentWithOperatorAssignment" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoreLazyOperators" value="true" />
<option name="ignoreObscureOperators" value="false" />
</inspection_tool>
<inspection_tool class="ReplaceCallWithComparison" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="RequireNonNull" enabled="false" level="INFORMATION" enabled_by_default="false" />
<inspection_tool class="ResourceParameter" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="RestSignature" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="ResultOfObjectAllocationIgnored" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ReturnOfCollectionField" enabled="false" level="WARNING" enabled_by_default="false">
<option name="ignorePrivateMethods" value="true" />
</inspection_tool>
<inspection_tool class="ReturnOfDateField" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="ScalarTypeRequired" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="SerializableClassInSecureContext" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="SetReplaceableByEnumSet" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="SimplifiableAnnotation" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="SimplifiableEqualsExpression" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="SingleCharAlternation" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="SizeReplaceableByIsEmpty" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="StaticCallOnSubclass" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="StaticFieldReferenceOnSubclass" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="StaticImport" enabled="true" level="WARNING" enabled_by_default="true">
<option name="allowedClasses">
<set>
<option value="org.junit.Assert" />
</set>
</option>
</inspection_tool>
<inspection_tool class="StaticInheritance" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="StaticMethodNamingConvention" enabled="false" level="WARNING" enabled_by_default="false">
<option name="m_regex" value="[a-z][A-Za-z\d]*" />
<option name="m_minLength" value="4" />
<option name="m_maxLength" value="32" />
</inspection_tool>
<inspection_tool class="StaticNonFinalField" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="StaticVariableNamingConvention" enabled="false" level="WARNING" enabled_by_default="false">
<option name="checkMutableFinals" value="false" />
<option name="m_regex" value="s_[a-z][A-Za-z\d]*" />
<option name="m_minLength" value="5" />
<option name="m_maxLength" value="32" />
</inspection_tool>
<inspection_tool class="StaticnessMismatch" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="StringBufferToStringInConcatenation" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="StringConcatenationInFormatCall" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="StringConcatenationMissingWhitespace" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="StringEqualsCharSequence" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="StringEqualsEmptyString" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="StringReplaceableByStringBuffer" enabled="true" level="WARNING" enabled_by_default="true">
<option name="onlyWarnOnLoop" value="true" />
</inspection_tool>
<inspection_tool class="SubtractionInCompareTo" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="SuperClassHasFrequentlyUsedInheritors" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="SuspiciousArrayCast" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="SuspiciousIndentAfterControlStatement" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="SwitchStatementWithConfusingDeclaration" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="SynchronizeOnLock" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="SynchronizeOnThis" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="SynchronizedMethod" enabled="true" level="WARNING" enabled_by_default="true">
<option name="m_includeNativeMethods" value="true" />
<option name="ignoreSynchronizedSuperMethods" value="true" />
</inspection_tool>
<inspection_tool class="SynchronizedOnLiteralObject" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="TemplateArgumentsIssues" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="TestMethodWithoutAssertion" enabled="false" level="WARNING" enabled_by_default="false">
<option name="assertionMethods" value="org.junit.Assert,assert.*|fail.*,junit.framework.Assert,assert.*|fail.*,org.junit.jupiter.api.Assertions,assert.*|fail.*,org.mockito.Mockito,verify.*,org.mockito.InOrder,verify,org.junit.rules.ExpectedException,expect.*,org.hamcrest.MatcherAssert,assertThat" />
</inspection_tool>
<inspection_tool class="TestNGMethodNamingConvention" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="ThisEscapedInConstructor" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ThrowCaughtLocally" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoreRethrownExceptions" value="true" />
</inspection_tool>
<inspection_tool class="ThrowsRuntimeException" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="TooBroadScope" enabled="true" level="WARNING" enabled_by_default="true">
<option name="m_allowConstructorAsInitializer" value="false" />
<option name="m_onlyLookAtBlocks" value="true" />
</inspection_tool>
<inspection_tool class="TrivialMethodReference" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="TrivialStringConcatenation" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="TypeMayBeWeakened" enabled="true" level="WARNING" enabled_by_default="true">
<option name="useRighthandTypeAsWeakestTypeInAssignments" value="true" />
<option name="useParameterizedTypeForCollectionMethods" value="true" />
<option name="doNotWeakenToJavaLangObject" value="true" />
<option name="onlyWeakentoInterface" value="true" />
</inspection_tool>
<inspection_tool class="TypeParameterExtendsFinalClass" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="TypeParameterNamingConvention" enabled="false" level="WARNING" enabled_by_default="false">
<option name="m_regex" value="[A-Z][A-Za-z\d]*" />
<option name="m_minLength" value="1" />
<option name="m_maxLength" value="1" />
</inspection_tool>
<inspection_tool class="UnaryPlus" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="UnnecessarilyQualifiedInnerClassAccess" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoreReferencesNeedingImport" value="true" />
</inspection_tool>
<inspection_tool class="UnnecessaryBlockStatement" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoreSwitchBranches" value="false" />
</inspection_tool>
<inspection_tool class="UnnecessaryConstantArrayCreationExpression" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="UnnecessaryConstructor" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="UnnecessaryExplicitNumericCast" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="UnnecessaryFullyQualifiedName" enabled="true" level="WARNING" enabled_by_default="true">
<option name="m_ignoreJavadoc" value="false" />
<option name="ignoreInModuleStatements" value="true" />
</inspection_tool>
<inspection_tool class="UnnecessaryInheritDoc" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="UnnecessaryJavaDocLink" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoreInlineLinkToSuper" value="false" />
</inspection_tool>
<inspection_tool class="UnnecessaryQualifierForThis" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="UnnecessarySuperConstructor" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="UnnecessarySuperQualifier" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="UnnecessaryThis" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="UnnecessaryToStringCall" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="UnnecessaryUnaryMinus" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="UnsecureRandomNumberGeneration" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="UnusedCatchParameter" enabled="true" level="WARNING" enabled_by_default="true">
<option name="m_ignoreCatchBlocksWithComments" value="false" />
<option name="m_ignoreTestCases" value="false" />
</inspection_tool>
<inspection_tool class="UnusedImport" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="UpperCaseFieldNameNotConstant" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="UseOfClone" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="UseOfObsoleteDateTimeApi" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="UtilityClassWithPublicConstructor" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="UtilityClassWithoutPrivateConstructor" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignorableAnnotations">
<value />
</option>
<option name="ignoreClassesWithOnlyMain" value="false" />
</inspection_tool>
<inspection_tool class="WeakerAccess" enabled="true" level="WARNING" enabled_by_default="true">
<option name="SUGGEST_PACKAGE_LOCAL_FOR_MEMBERS" value="false" />
<option name="SUGGEST_PACKAGE_LOCAL_FOR_TOP_CLASSES" value="true" />
<option name="SUGGEST_PRIVATE_FOR_INNERS" value="false" />
</inspection_tool>
<inspection_tool class="WhileLoopSpinsOnField" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoreNonEmtpyLoops" value="false" />
</inspection_tool>
<inspection_tool class="ZeroLengthArrayInitialization" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="unused" enabled="true" level="WARNING" enabled_by_default="true" klass="packageLocal" inner_class="protected" field="protected" method="protected" parameter="protected">
<option name="LOCAL_VARIABLE" value="true" />
<option name="FIELD" value="true" />
<option name="METHOD" value="true" />
<option name="CLASS" value="true" />
<option name="PARAMETER" value="true" />
<option name="REPORT_PARAMETER_FOR_PUBLIC_METHODS" value="false" />
<option name="ADD_MAINS_TO_ENTRIES" value="true" />
<option name="ADD_APPLET_TO_ENTRIES" value="true" />
<option name="ADD_SERVLET_TO_ENTRIES" value="true" />
<option name="ADD_NONJAVA_TO_ENTRIES" value="true" />
</inspection_tool>
</profile>
</component>
+6
View File
@@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="PROJECT_PROFILE" value="Default" />
<version value="1.0" />
</settings>
</component>
+30 -5
View File
@@ -1,15 +1,40 @@
# Android GUI for [AmneziaWG](https://amnezia.org/learn-more/31_amneziawg)
# Android GUI for [WireGuard](https://www.wireguard.com/)
**[Download from the Play Store](https://play.google.com/store/apps/details?id=org.amnezia.awg)**
**[Download from the Play Store](https://play.google.com/store/apps/details?id=com.wireguard.android)**
This is an Android GUI for [AmneziaWG](https://amnezia.org/learn-more/31_amneziawg).
This is an Android GUI for [WireGuard](https://www.wireguard.com/). It [opportunistically uses the kernel implementation](https://git.zx2c4.com/android_kernel_wireguard/about/), and falls back to using the non-root [userspace implementation](https://git.zx2c4.com/wireguard-go/about/).
## Building
```
$ git clone --recurse-submodules https://github.com/amnezia-vpn/amneziawg-android
$ cd amneziawg-android
$ git clone --recurse-submodules https://git.zx2c4.com/wireguard-android
$ cd wireguard-android
$ ./gradlew assembleRelease
```
macOS users may need [flock(1)](https://github.com/discoteq/flock).
## Embedding
The tunnel library is [on Maven Central](https://search.maven.org/artifact/com.wireguard.android/tunnel), alongside [extensive class library documentation](https://javadoc.io/doc/com.wireguard.android/tunnel).
```
implementation 'com.wireguard.android:tunnel:$wireguardTunnelVersion'
```
The library makes use of Java 8 features, so be sure to support those in your gradle configuration with [desugaring](https://developer.android.com/studio/write/java8-support#library-desugaring):
```
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
coreLibraryDesugaringEnabled = true
}
dependencies {
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:2.0.3"
}
```
## Translating
Please help us translate the app into several languages on [our translation platform](https://crowdin.com/project/WireGuard).
+7
View File
@@ -4,3 +4,10 @@ plugins {
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.kapt) apply false
}
tasks {
wrapper {
gradleVersion = "8.14"
distributionSha256Sum = "61ad310d3c7d3e5da131b76bbf22b5a4c0786e9d892dae8c1658d4b484de3caa"
}
}
+4 -35
View File
@@ -1,6 +1,6 @@
amneziawgVersionCode=9
amneziawgVersionName=2.0.0
amneziawgPackageName=org.amnezia.awg
wireguardVersionCode=513
wireguardVersionName=1.0.20250519
wireguardPackageName=com.wireguard.android
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
@@ -17,50 +17,20 @@ android.useAndroidX=true
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m --add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
# Use Java 17+ for Gradle. Set JAVA_HOME or org.gradle.java.home if needed.
# On macOS with Homebrew: org.gradle.java.home=/opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk/Contents/Home
# On Linux: org.gradle.java.home=/usr/lib/jvm/java-17-openjdk
# Kotlin daemon JVM args to allow KAPT access to internal JDK modules
kotlin.daemon.jvmargs=-Xmx1536m --add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
org.gradle.jvmargs=-Xmx1536m
# Turn off AP discovery in compile path to enable compile avoidance
kapt.include.compile.classpath=false
# Enable non-transitive R class namespacing where each library only contains
# references to the resources it declares instead of declarations plus all
# transitive dependency references.
android.nonTransitiveRClass=true
# Experimental AGP flags
# Generate compile-time only R class for app modules.
android.enableAppCompileTimeRClass=true
# Keep AAPT2 daemons alive between incremental builds.
android.keepWorkerActionServicesBetweenBuilds=true
# Make R fields non-final to improve build speeds.
# http://tools.android.com/tips/non-constant-fields
android.nonFinalResIds=true
# Enable the newly refactored resource shrinker.
android.experimental.enableNewResourceShrinker=true
# Enable precise shrinking in the new resource shrinker.
android.experimental.enableNewResourceShrinker.preciseShrinking=true
# Generate manifest class as a .class directly rather than a Java source file.
android.generateManifestClass=true
# Generate the text map of source sets and absolute paths to allow
# generating relative paths from absolute paths later in the build.
android.experimental.enableSourceSetPathsMap=true
# Use relative paths for better Gradle caching of library build tasks
android.experimental.cacheCompileLibResources=true
# Default Android build features
# Disable BuildConfig generation by default
android.defaults.buildfeatures.buildconfig=false
# Disable AIDL stub generation by default
android.defaults.buildfeatures.aidl=false
# Disable RenderScript compilation by default
android.defaults.buildfeatures.renderscript=false
# Disable resource values generation by default in libraries
android.defaults.buildfeatures.resvalues=false
# Disable shader compilation by default
@@ -70,7 +40,6 @@ android.library.defaults.buildfeatures.androidresources=false
# Suppress warnings for some features that aren't yet stabilized
android.suppressUnsupportedOptionWarnings=android.keepWorkerActionServicesBetweenBuilds,\
android.experimental.enableNewResourceShrinker.preciseShrinking,\
android.enableAppCompileTimeRClass,\
android.suppressUnsupportedOptionWarnings
+14 -14
View File
@@ -1,22 +1,22 @@
[versions]
agp = "8.3.0"
kotlin = "1.9.20"
agp = "8.10.0"
kotlin = "2.1.20"
[libraries]
androidx-activity-ktx = "androidx.activity:activity-ktx:1.8.2"
androidx-annotation = "androidx.annotation:annotation:1.7.1"
androidx-appcompat = "androidx.appcompat:appcompat:1.6.1"
androidx-activity-ktx = "androidx.activity:activity-ktx:1.10.1"
androidx-annotation = "androidx.annotation:annotation:1.9.1"
androidx-appcompat = "androidx.appcompat:appcompat:1.7.0"
androidx-biometric = "androidx.biometric:biometric:1.1.0"
androidx-collection = "androidx.collection:collection:1.4.0"
androidx-constraintlayout = "androidx.constraintlayout:constraintlayout:2.1.4"
androidx-coordinatorlayout = "androidx.coordinatorlayout:coordinatorlayout:1.2.0"
androidx-core-ktx = "androidx.core:core-ktx:1.12.0"
androidx-datastore-preferences = "androidx.datastore:datastore-preferences:1.0.0"
androidx-fragment-ktx = "androidx.fragment:fragment-ktx:1.6.2"
androidx-lifecycle-runtime-ktx = "androidx.lifecycle:lifecycle-runtime-ktx:2.7.0"
androidx-collection = "androidx.collection:collection:1.5.0"
androidx-constraintlayout = "androidx.constraintlayout:constraintlayout:2.2.1"
androidx-coordinatorlayout = "androidx.coordinatorlayout:coordinatorlayout:1.3.0"
androidx-core-ktx = "androidx.core:core-ktx:1.16.0"
androidx-datastore-preferences = "androidx.datastore:datastore-preferences:1.1.6"
androidx-fragment-ktx = "androidx.fragment:fragment-ktx:1.8.6"
androidx-lifecycle-runtime-ktx = "androidx.lifecycle:lifecycle-runtime-ktx:2.9.0"
androidx-preference-ktx = "androidx.preference:preference-ktx:1.2.1"
desugarJdkLibs = "com.android.tools:desugar_jdk_libs:2.0.4"
google-material = "com.google.android.material:material:1.11.0"
desugarJdkLibs = "com.android.tools:desugar_jdk_libs:2.1.5"
google-material = "com.google.android.material:material:1.12.0"
jsr305 = "com.google.code.findbugs:jsr305:3.0.2"
junit = "junit:junit:4.13.2"
kotlinx-coroutines-android = "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3"
Binary file not shown.
+4 -1
View File
@@ -1,5 +1,8 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionSha256Sum=61ad310d3c7d3e5da131b76bbf22b5a4c0786e9d892dae8c1658d4b484de3caa
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored
+5 -2
View File
@@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
#
@@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
+3 -15
View File
@@ -1,4 +1,4 @@
import com.android.build.api.dsl.SettingsExtension
@file:Suppress("UnstableApiUsage")
pluginManagement {
repositories {
@@ -8,27 +8,15 @@ pluginManagement {
}
}
@Suppress("UnstableApiUsage")
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositoriesMode = RepositoriesMode.FAIL_ON_PROJECT_REPOS
repositories {
google()
mavenCentral()
}
}
plugins {
id("com.android.settings") version "8.3.0"
}
rootProject.name = "amneziawg-android"
rootProject.name = "wireguard-android"
include(":tunnel")
include(":ui")
configure<SettingsExtension> {
buildToolsVersion = "35.0.0"
compileSdk = 35
minSdk = 24
ndkVersion = "26.1.10909125"
}
+10
View File
@@ -0,0 +1,10 @@
#!/bin/bash
if [[ $# -ne 1 ]]; then
echo "Download https://crowdin.com/backend/download/project/wireguard.zip and provide path as argument"
exit 1
fi
set -ex
bsdtar -C ui/src/main/res -x -f "$1" --strip-components 5 wireguard-android
find ui/src/main/res -name strings.xml -exec bash -c '[[ $(xmllint --xpath "count(//resources/*)" {}) -ne 0 ]] || rm -rf "$(dirname {})"' \;
+71 -4
View File
@@ -2,19 +2,24 @@
import org.gradle.api.tasks.testing.logging.TestLogEvent
val pkg: String = providers.gradleProperty("amneziawgPackageName").get()
val cmakeAndroidPackageName: String = providers.environmentVariable("ANDROID_PACKAGE_NAME").getOrElse(pkg)
val pkg: String = providers.gradleProperty("wireguardPackageName").get()
plugins {
alias(libs.plugins.android.library)
`maven-publish`
signing
}
android {
compileSdk = 36
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
namespace = "${pkg}.tunnel"
defaultConfig {
minSdk = 21
}
externalNativeBuild {
cmake {
path("tools/CMakeLists.txt")
@@ -35,14 +40,14 @@ android {
release {
externalNativeBuild {
cmake {
arguments("-DANDROID_PACKAGE_NAME=${cmakeAndroidPackageName}")
arguments("-DANDROID_PACKAGE_NAME=${pkg}")
}
}
}
debug {
externalNativeBuild {
cmake {
arguments("-DANDROID_PACKAGE_NAME=${cmakeAndroidPackageName}.debug")
arguments("-DANDROID_PACKAGE_NAME=${pkg}.debug")
}
}
}
@@ -51,6 +56,12 @@ android {
disable += "LongLogTag"
disable += "NewApi"
}
publishing {
singleVariant("release") {
withJavadocJar()
withSourcesJar()
}
}
}
dependencies {
@@ -59,3 +70,59 @@ dependencies {
compileOnly(libs.jsr305)
testImplementation(libs.junit)
}
publishing {
publications {
register<MavenPublication>("release") {
groupId = pkg
artifactId = "tunnel"
version = providers.gradleProperty("wireguardVersionName").get()
afterEvaluate {
from(components["release"])
}
pom {
name = "WireGuard Tunnel Library"
description = "Embeddable tunnel library for WireGuard for Android"
url = "https://www.wireguard.com/"
licenses {
license {
name = "The Apache Software License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
distribution = "repo"
}
}
scm {
connection = "scm:git:https://git.zx2c4.com/wireguard-android"
developerConnection = "scm:git:https://git.zx2c4.com/wireguard-android"
url = "https://git.zx2c4.com/wireguard-android"
}
developers {
organization {
name = "WireGuard"
url = "https://www.wireguard.com/"
}
developer {
name = "WireGuard"
email = "team@wireguard.com"
}
}
}
}
}
repositories {
maven {
name = "sonatype"
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = providers.environmentVariable("SONATYPE_USER").orNull
password = providers.environmentVariable("SONATYPE_PASSWORD").orNull
}
}
}
}
signing {
useGpgCmd()
sign(publishing.publications)
}
+2 -2
View File
@@ -1,5 +1,5 @@
<!--
~ Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
~ Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
~ SPDX-License-Identifier: Apache-2.0
-->
@@ -7,7 +7,7 @@
<application>
<service
android:name="org.amnezia.awg.backend.GoBackend$VpnService"
android:name="com.wireguard.android.backend.GoBackend$VpnService"
android:permission="android.permission.BIND_VPN_SERVICE"
android:exported="false">
<intent-filter>
@@ -1,19 +1,19 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.backend;
package com.wireguard.android.backend;
import org.amnezia.awg.config.Config;
import org.amnezia.awg.util.NonNullForAll;
import com.wireguard.config.Config;
import com.wireguard.util.NonNullForAll;
import java.util.Set;
import androidx.annotation.Nullable;
/**
* Interface for implementations of the AmneziaWG secure network tunnel.
* Interface for implementations of the WireGuard secure network tunnel.
*/
@NonNullForAll
@@ -34,16 +34,6 @@ public interface Backend {
*/
Tunnel.State getState(Tunnel tunnel) throws Exception;
/**
* Get the last handshake time for a tunnel.
*
* @param tunnel The tunnel to examine.
* @return Last handshake time in seconds (>=0 means valid handshake time, 0 means no handshake yet),
* -1 if parsing failed, -2 on command execution error, -3 if tunnel not active.
* @throws Exception Exception raised when retrieving handshake time.
*/
long getLastHandshake(Tunnel tunnel) throws Exception;
/**
* Get statistics about traffic and errors on this tunnel. If the tunnel is not running, the
* statistics object will be filled with zero values.
@@ -74,11 +64,4 @@ public interface Backend {
* @throws Exception Exception raised while changing state.
*/
Tunnel.State setState(Tunnel tunnel, Tunnel.State state, @Nullable Config config) throws Exception;
/**
* Set the callback for status changes (e.g. handshake / connection state).
*
* @param callback The callback to invoke on status changes, or null to clear.
*/
void setStatusCallback(@Nullable StatusCallback callback);
}
@@ -1,11 +1,11 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.backend;
package com.wireguard.android.backend;
import org.amnezia.awg.util.NonNullForAll;
import com.wireguard.util.NonNullForAll;
/**
* A subclass of {@link Exception} that encapsulates the reasons for a failure originating in
@@ -50,7 +50,7 @@ public final class BackendException extends Exception {
*/
public enum Reason {
UNKNOWN_KERNEL_MODULE_NAME,
AWG_QUICK_CONFIG_ERROR_CODE,
WG_QUICK_CONFIG_ERROR_CODE,
TUNNEL_MISSING_CONFIG,
VPN_NOT_AUTHORIZED,
UNABLE_TO_START_VPN,
@@ -1,9 +1,9 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.backend;
package com.wireguard.android.backend;
import android.content.Context;
import android.content.Intent;
@@ -12,18 +12,19 @@ import android.os.ParcelFileDescriptor;
import android.system.OsConstants;
import android.util.Log;
import org.amnezia.awg.backend.BackendException.Reason;
import org.amnezia.awg.backend.Tunnel.State;
import org.amnezia.awg.util.SharedLibraryLoader;
import org.amnezia.awg.config.Config;
import org.amnezia.awg.config.InetEndpoint;
import org.amnezia.awg.config.InetNetwork;
import org.amnezia.awg.config.Peer;
import org.amnezia.awg.crypto.Key;
import org.amnezia.awg.crypto.KeyFormatException;
import org.amnezia.awg.util.NonNullForAll;
import com.wireguard.android.backend.BackendException.Reason;
import com.wireguard.android.backend.Tunnel.State;
import com.wireguard.android.util.SharedLibraryLoader;
import com.wireguard.config.Config;
import com.wireguard.config.InetEndpoint;
import com.wireguard.config.InetNetwork;
import com.wireguard.config.Peer;
import com.wireguard.crypto.Key;
import com.wireguard.crypto.KeyFormatException;
import com.wireguard.util.NonNullForAll;
import java.net.InetAddress;
import java.time.Instant;
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.ExecutionException;
@@ -35,24 +36,20 @@ import java.util.concurrent.TimeoutException;
import androidx.annotation.Nullable;
import androidx.collection.ArraySet;
import static org.amnezia.awg.GoBackend.*;
/**
* Implementation of {@link Backend} that uses the amneziawg-go userspace implementation to provide
* AmneziaWG tunnels.
* Implementation of {@link Backend} that uses the wireguard-go userspace implementation to provide
* WireGuard tunnels.
*/
@NonNullForAll
public final class GoBackend implements Backend {
private static final int DNS_RESOLUTION_RETRIES = 10;
private static final String TAG = "AmneziaWG/GoBackend";
private static final String TAG = "WireGuard/GoBackend";
@Nullable private static AlwaysOnCallback alwaysOnCallback;
private static GhettoCompletableFuture<VpnService> vpnService = new GhettoCompletableFuture<>();
private final Context context;
@Nullable private Config currentConfig;
@Nullable private Tunnel currentTunnel;
private int currentTunnelHandle = -1;
@Nullable private Thread statusThread;
@Nullable private StatusCallback statusCallback;
/**
* Public constructor for GoBackend.
@@ -74,7 +71,17 @@ public final class GoBackend implements Backend {
alwaysOnCallback = cb;
}
@Nullable private static native String wgGetConfig(int handle);
private static native int wgGetSocketV4(int handle);
private static native int wgGetSocketV6(int handle);
private static native void wgTurnOff(int handle);
private static native int wgTurnOn(String ifName, int tunFd, String settings);
private static native String wgVersion();
/**
* Method to get the names of running tunnels.
@@ -113,7 +120,7 @@ public final class GoBackend implements Backend {
final Statistics stats = new Statistics();
if (tunnel != currentTunnel || currentTunnelHandle == -1)
return stats;
final String config = awgGetConfig(currentTunnelHandle);
final String config = wgGetConfig(currentTunnelHandle);
if (config == null)
return stats;
Key key = null;
@@ -171,116 +178,14 @@ public final class GoBackend implements Backend {
return stats;
}
/**
* Get the last handshake time for a given {@link Tunnel}.
* Get the version of the underlying wireguard-go library.
*
* @param tunnel The tunnel to retrieve the last handshake time for.
* @return Last handshake time in seconds (>=0), -1 if no handshake found, -2 on error, -3 if tunnel not active.
*/
@Override
public long getLastHandshake(final Tunnel tunnel) {
if (tunnel != currentTunnel || currentTunnelHandle == -1)
return -3; // Tunnel not active
final String config = awgGetConfig(currentTunnelHandle);
if (config == null) {
Log.e(TAG, "Failed to get tunnel config");
return -2;
}
for (final String line : config.split("\\n")) {
if (line.startsWith("last_handshake_time_sec=")) {
try {
return Long.parseLong(line.substring(24));
} catch (final NumberFormatException ignored) {
Log.e(TAG, "Failed to parse last_handshake_time_sec");
return -2;
}
}
}
Log.e(TAG, "Failed to get last_handshake_time_sec");
return -1;
}
/**
* Set a callback to be notified when connection status changes.
*
* @param callback The callback to invoke on status change
*/
public void setStatusCallback(@Nullable final StatusCallback callback) {
this.statusCallback = callback;
}
/**
* Launch a background thread to poll handshake status and determine connection state.
* This is called after tunnel creation to wait for the first successful handshake.
*/
private void launchStatusJob() {
stopStatusJob();
Log.d(TAG, "Launch status job");
statusThread = new Thread(() -> {
while (!Thread.currentThread().isInterrupted()) {
final long lastHandshake = getLastHandshake(currentTunnel);
// Check if tunnel is no longer active (race condition protection)
if (lastHandshake == -3L) {
Log.d(TAG, "Tunnel is no longer active, stopping status job");
break;
}
// 0 means no handshake yet, wait and retry
if (lastHandshake == 0L) {
try {
Thread.sleep(1000);
} catch (final InterruptedException e) {
Thread.currentThread().interrupt();
break;
}
continue;
}
// Only positive handshake time indicates successful connection
// -1 may be returned if unable to parse output (doesn't mean no connection)
// -2 indicates command execution error (also doesn't mean no connection)
if (lastHandshake > 0L) {
if (statusCallback != null) {
statusCallback.onStatusChanged(true);
}
break;
}
// For -1 or -2, retry after delay instead of reporting disconnected
try {
Thread.sleep(1000);
} catch (final InterruptedException e) {
Thread.currentThread().interrupt();
break;
}
}
statusThread = null;
}, "StatusJob");
statusThread.start();
}
/**
* Stop the status polling thread if running.
*/
private void stopStatusJob() {
if (statusThread != null) {
statusThread.interrupt();
statusThread = null;
}
}
/**
* Get the version of the underlying amneziawg-go library.
*
* @return {@link String} value of the version of the amneziawg-go library.
* @return {@link String} value of the version of the wireguard-go library.
*/
@Override
public String getVersion() {
return awgVersion();
return wgVersion();
}
/**
@@ -370,7 +275,7 @@ public final class GoBackend implements Backend {
}
// Build config
final String goConfig = config.toAwgUserspaceString();
final String goConfig = config.toWgUserspaceString();
// Create the vpn tunnel with android API
final VpnService.Builder builder = service.getBuilder();
@@ -417,8 +322,8 @@ public final class GoBackend implements Backend {
try (final ParcelFileDescriptor tun = builder.establish()) {
if (tun == null)
throw new BackendException(Reason.TUN_CREATION_ERROR);
Log.d(TAG, "Go backend " + awgVersion());
currentTunnelHandle = awgTurnOn(tunnel.getName(), tun.detachFd(), goConfig);
Log.d(TAG, "Go backend " + wgVersion());
currentTunnelHandle = wgTurnOn(tunnel.getName(), tun.detachFd(), goConfig);
}
if (currentTunnelHandle < 0)
throw new BackendException(Reason.GO_ACTIVATION_ERROR_CODE, currentTunnelHandle);
@@ -426,21 +331,18 @@ public final class GoBackend implements Backend {
currentTunnel = tunnel;
currentConfig = config;
service.protect(awgGetSocketV4(currentTunnelHandle));
service.protect(awgGetSocketV6(currentTunnelHandle));
launchStatusJob();
service.protect(wgGetSocketV4(currentTunnelHandle));
service.protect(wgGetSocketV6(currentTunnelHandle));
} else {
if (currentTunnelHandle == -1) {
Log.w(TAG, "Tunnel already down");
return;
}
stopStatusJob();
int handleToClose = currentTunnelHandle;
currentTunnel = null;
currentTunnelHandle = -1;
currentConfig = null;
awgTurnOff(handleToClose);
wgTurnOff(handleToClose);
try {
vpnService.get(0, TimeUnit.NANOSECONDS).stopSelf();
} catch (final TimeoutException ignored) { }
@@ -508,7 +410,7 @@ public final class GoBackend implements Backend {
final Tunnel tunnel = owner.currentTunnel;
if (tunnel != null) {
if (owner.currentTunnelHandle != -1)
awgTurnOff(owner.currentTunnelHandle);
wgTurnOff(owner.currentTunnelHandle);
owner.currentTunnel = null;
owner.currentTunnelHandle = -1;
owner.currentConfig = null;
@@ -1,17 +1,18 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.backend;
package com.wireguard.android.backend;
import android.os.SystemClock;
import org.amnezia.awg.crypto.Key;
import org.amnezia.awg.util.NonNullForAll;
import com.wireguard.crypto.Key;
import com.wireguard.util.NonNullForAll;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import androidx.annotation.Nullable;
@@ -30,12 +31,12 @@ public class Statistics {
/**
* Add a peer and its current stats to the internal map.
*
* @param key An AmneziaWG public key bound to a particular peer
* @param rxBytes The received traffic for the {@link org.amnezia.config.Peer} referenced by
* @param key A WireGuard public key bound to a particular peer
* @param rxBytes The received traffic for the {@link com.wireguard.config.Peer} referenced by
* the provided {@link Key}. This value is in bytes
* @param txBytes The transmitted traffic for the {@link org.amnezia.config.Peer} referenced by
* @param txBytes The transmitted traffic for the {@link com.wireguard.config.Peer} referenced by
* the provided {@link Key}. This value is in bytes.
* @param latestHandshake The timestamp of the latest handshake for the {@link org.amnezia.config.Peer}
* @param latestHandshake The timestamp of the latest handshake for the {@link com.wireguard.config.Peer}
* referenced by the provided {@link Key}. The value is in epoch milliseconds.
*/
void add(final Key key, final long rxBytes, final long txBytes, final long latestHandshake) {
@@ -53,9 +54,9 @@ public class Statistics {
}
/**
* Get the statistics for the {@link org.amnezia.config.Peer} referenced by the provided {@link Key}
* Get the statistics for the {@link com.wireguard.config.Peer} referenced by the provided {@link Key}
*
* @param peer A {@link Key} representing a {@link org.amnezia.config.Peer}.
* @param peer A {@link Key} representing a {@link com.wireguard.config.Peer}.
* @return a {@link PeerStats} representing various statistics about this peer.
*/
@Nullable
@@ -66,8 +67,8 @@ public class Statistics {
/**
* Get the list of peers being tracked by this instance.
*
* @return An array of {@link Key} instances representing AmneziaWG
* {@link org.amnezia.config.Peer}s
* @return An array of {@link Key} instances representing WireGuard
* {@link com.wireguard.config.Peer}s
*/
public Key[] peers() {
return stats.keySet().toArray(new Key[0]);
@@ -1,16 +1,16 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.backend;
package com.wireguard.android.backend;
import org.amnezia.awg.util.NonNullForAll;
import com.wireguard.util.NonNullForAll;
import java.util.regex.Pattern;
/**
* Represents an AmneziaWG tunnel.
* Represents a WireGuard tunnel.
*/
@NonNullForAll
@@ -1,25 +1,26 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.backend;
package com.wireguard.android.backend;
import android.content.Context;
import android.util.Log;
import android.util.Pair;
import org.amnezia.awg.backend.BackendException.Reason;
import org.amnezia.awg.backend.Tunnel.State;
import org.amnezia.awg.util.RootShell;
import org.amnezia.awg.util.ToolsInstaller;
import org.amnezia.awg.config.Config;
import org.amnezia.awg.crypto.Key;
import org.amnezia.awg.util.NonNullForAll;
import com.wireguard.android.backend.BackendException.Reason;
import com.wireguard.android.backend.Tunnel.State;
import com.wireguard.android.util.RootShell;
import com.wireguard.android.util.ToolsInstaller;
import com.wireguard.config.Config;
import com.wireguard.crypto.Key;
import com.wireguard.util.NonNullForAll;
import java.io.File;
import java.io.FileOutputStream;
import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -34,30 +35,27 @@ import java.util.Set;
import androidx.annotation.Nullable;
/**
* Implementation of {@link Backend} that uses the kernel module and {@code awg-quick} to provide
* AmneziaWG tunnels.
* Implementation of {@link Backend} that uses the kernel module and {@code wg-quick} to provide
* WireGuard tunnels.
*/
@NonNullForAll
public final class AwgQuickBackend implements Backend {
private static final String TAG = "AmneziaWG/AwgQuickBackend";
public final class WgQuickBackend implements Backend {
private static final String TAG = "WireGuard/WgQuickBackend";
private final File localTemporaryDir;
private final RootShell rootShell;
private final Map<Tunnel, Config> runningConfigs = new HashMap<>();
private final ToolsInstaller toolsInstaller;
private boolean multipleTunnels;
@Nullable private Thread statusThread;
@Nullable private StatusCallback statusCallback;
@Nullable private Tunnel currentTunnel;
public AwgQuickBackend(final Context context, final RootShell rootShell, final ToolsInstaller toolsInstaller) {
public WgQuickBackend(final Context context, final RootShell rootShell, final ToolsInstaller toolsInstaller) {
localTemporaryDir = new File(context.getCacheDir(), "tmp");
this.rootShell = rootShell;
this.toolsInstaller = toolsInstaller;
}
public static boolean hasKernelSupport() {
return new File("/sys/module/amneziawg").exists();
return new File("/sys/module/wireguard").exists();
}
@Override
@@ -66,13 +64,13 @@ public final class AwgQuickBackend implements Backend {
// Don't throw an exception here or nothing will show up in the UI.
try {
toolsInstaller.ensureToolsAvailable();
if (rootShell.run(output, "awg show interfaces") != 0 || output.isEmpty())
if (rootShell.run(output, "wg show interfaces") != 0 || output.isEmpty())
return Collections.emptySet();
} catch (final Exception e) {
Log.w(TAG, "Unable to enumerate running tunnels", e);
return Collections.emptySet();
}
// awg puts all interface names on the same line. Split them into separate elements.
// wg puts all interface names on the same line. Split them into separate elements.
return Set.of(output.get(0).split(" "));
}
@@ -81,112 +79,12 @@ public final class AwgQuickBackend implements Backend {
return getRunningTunnelNames().contains(tunnel.getName()) ? State.UP : State.DOWN;
}
@Override
public long getLastHandshake(final Tunnel tunnel) {
if (getState(tunnel) != State.UP) {
return -3; // Tunnel not active
}
final Collection<String> output = new ArrayList<>();
try {
if (rootShell.run(output, String.format("awg show '%s' latest-handshakes", tunnel.getName())) != 0) {
Log.e(TAG, "Failed to get latest handshakes");
return -2;
}
} catch (final Exception e) {
Log.e(TAG, "Failed to get latest handshakes", e);
return -2;
}
for (final String line : output) {
final String[] parts = line.split("\\t");
if (parts.length >= 2) {
try {
return Long.parseLong(parts[1]);
} catch (final NumberFormatException ignored) {
Log.e(TAG, "Failed to parse handshake time");
return -2;
}
}
}
Log.e(TAG, "No handshake time found");
return -1;
}
/**
* Set a callback to be notified when connection status changes.
*
* @param callback The callback to invoke on status change
*/
public void setStatusCallback(@Nullable final StatusCallback callback) {
this.statusCallback = callback;
}
/**
* Launch a background thread to poll handshake status and determine connection state.
* This is called after tunnel creation to wait for the first successful handshake.
*/
private void launchStatusJob() {
stopStatusJob();
Log.d(TAG, "Launch status job");
statusThread = new Thread(() -> {
while (!Thread.currentThread().isInterrupted()) {
final long lastHandshake = getLastHandshake(currentTunnel);
// Check if tunnel is no longer active (race condition protection)
if (lastHandshake == -3L) {
Log.d(TAG, "Tunnel is no longer active, stopping status job");
break;
}
// 0 means no handshake yet, wait and retry
if (lastHandshake == 0L) {
try {
Thread.sleep(1000);
} catch (final InterruptedException e) {
Thread.currentThread().interrupt();
break;
}
continue;
}
// Only positive handshake time indicates successful connection
// -1 may be returned if unable to parse output (doesn't mean no connection)
// -2 indicates command execution error (also doesn't mean no connection)
if (lastHandshake > 0L) {
if (statusCallback != null) {
statusCallback.onStatusChanged(true);
}
break;
}
// For -1 or -2, retry after delay instead of reporting disconnected
try {
Thread.sleep(1000);
} catch (final InterruptedException e) {
Thread.currentThread().interrupt();
break;
}
}
statusThread = null;
}, "StatusJob");
statusThread.start();
}
/**
* Stop the status polling thread if running.
*/
private void stopStatusJob() {
if (statusThread != null) {
statusThread.interrupt();
statusThread = null;
}
}
@Override
public Statistics getStatistics(final Tunnel tunnel) {
final Statistics stats = new Statistics();
final Collection<String> output = new ArrayList<>();
try {
if (rootShell.run(output, String.format("awg show '%s' dump", tunnel.getName())) != 0)
if (rootShell.run(output, String.format("wg show '%s' dump", tunnel.getName())) != 0)
return stats;
} catch (final Exception ignored) {
return stats;
@@ -206,7 +104,7 @@ public final class AwgQuickBackend implements Backend {
@Override
public String getVersion() throws Exception {
final List<String> output = new ArrayList<>();
if (rootShell.run(output, "cat /sys/module/amneziawg/version") != 0 || output.isEmpty())
if (rootShell.run(output, "cat /sys/module/wireguard/version") != 0 || output.isEmpty())
throw new BackendException(Reason.UNKNOWN_KERNEL_MODULE_NAME);
return output.get(0);
}
@@ -276,27 +174,22 @@ public final class AwgQuickBackend implements Backend {
final File tempFile = new File(localTemporaryDir, tunnel.getName() + ".conf");
try (final FileOutputStream stream = new FileOutputStream(tempFile, false)) {
stream.write(config.toAwgQuickString().getBytes(StandardCharsets.UTF_8));
stream.write(config.toWgQuickString().getBytes(StandardCharsets.UTF_8));
}
String command = String.format("awg-quick %s '%s'",
String command = String.format("wg-quick %s '%s'",
state.toString().toLowerCase(Locale.ENGLISH), tempFile.getAbsolutePath());
if (state == State.UP)
command = "cat /sys/module/amneziawg/version && " + command;
command = "cat /sys/module/wireguard/version && " + command;
final int result = rootShell.run(null, command);
// noinspection ResultOfMethodCallIgnored
tempFile.delete();
if (result != 0)
throw new BackendException(Reason.AWG_QUICK_CONFIG_ERROR_CODE, result);
throw new BackendException(Reason.WG_QUICK_CONFIG_ERROR_CODE, result);
if (state == State.UP) {
if (state == State.UP)
runningConfigs.put(tunnel, config);
currentTunnel = tunnel;
launchStatusJob();
} else {
stopStatusJob();
else
runningConfigs.remove(tunnel);
currentTunnel = null;
}
tunnel.onStateChange(state);
}
@@ -1,15 +1,15 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.util;
package com.wireguard.android.util;
import android.content.Context;
import android.util.Log;
import org.amnezia.awg.util.RootShell.RootShellException.Reason;
import org.amnezia.awg.util.NonNullForAll;
import com.wireguard.android.util.RootShell.RootShellException.Reason;
import com.wireguard.util.NonNullForAll;
import java.io.BufferedReader;
import java.io.File;
@@ -29,7 +29,7 @@ import androidx.annotation.Nullable;
@NonNullForAll
public class RootShell {
private static final String SU = "su";
private static final String TAG = "AmneziaWG/RootShell";
private static final String TAG = "WireGuard/RootShell";
private final File localBinaryDir;
private final File localTemporaryDir;
@@ -1,15 +1,15 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.util;
package com.wireguard.android.util;
import android.content.Context;
import android.os.Build;
import android.util.Log;
import org.amnezia.awg.util.NonNullForAll;
import com.wireguard.util.NonNullForAll;
import java.io.File;
import java.io.FileOutputStream;
@@ -27,7 +27,7 @@ import androidx.annotation.RestrictTo.Scope;
@NonNullForAll
@RestrictTo(Scope.LIBRARY_GROUP)
public final class SharedLibraryLoader {
private static final String TAG = "AmneziaWG/SharedLibraryLoader";
private static final String TAG = "WireGuard/SharedLibraryLoader";
private SharedLibraryLoader() {
}
@@ -1,16 +1,16 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.util;
package com.wireguard.android.util;
import android.content.Context;
import android.system.OsConstants;
import android.util.Log;
import org.amnezia.awg.util.RootShell.RootShellException;
import org.amnezia.awg.util.NonNullForAll;
import com.wireguard.android.util.RootShell.RootShellException;
import com.wireguard.util.NonNullForAll;
import java.io.File;
import java.io.FileNotFoundException;
@@ -23,7 +23,7 @@ import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
/**
* Helper to install AmneziaWG tools to the system partition.
* Helper to install WireGuard tools to the system partition.
*/
@NonNullForAll
@@ -33,13 +33,13 @@ public final class ToolsInstaller {
public static final int NO = 0x2;
public static final int SYSTEM = 0x8;
public static final int YES = 0x1;
private static final String[] EXECUTABLES = {"awg", "awg-quick"};
private static final String[] EXECUTABLES = {"wg", "wg-quick"};
private static final File[] INSTALL_DIRS = {
new File("/system/xbin"),
new File("/system/bin"),
};
@Nullable private static final File INSTALL_DIR = getInstallDir();
private static final String TAG = "AmneziaWG/ToolsInstaller";
private static final String TAG = "WireGuard/ToolsInstaller";
private final Context context;
private final File localBinaryDir;
@@ -100,7 +100,7 @@ public final class ToolsInstaller {
"Tools were already extracted into our private binary dir");
areToolsAvailable = true;
} catch (final IOException e) {
Log.e(TAG, "The awg and awg-quick tools are not available", e);
Log.e(TAG, "The wg and wg-quick tools are not available", e);
areToolsAvailable = false;
}
}
@@ -134,8 +134,8 @@ public final class ToolsInstaller {
@RestrictTo(Scope.LIBRARY_GROUP)
public int install() throws RootShellException, IOException {
if (!context.getPackageName().startsWith("org.amnezia."))
throw new SecurityException("The tools may only be installed system-wide from the main AmneziaWG app.");
if (!context.getPackageName().startsWith("com.wireguard."))
throw new SecurityException("The tools may only be installed system-wide from the main WireGuard app.");
return willInstallAsMagiskModule() ? installMagisk() : installSystem();
}
@@ -143,12 +143,12 @@ public final class ToolsInstaller {
extract();
final StringBuilder script = new StringBuilder("set -ex; ");
script.append("trap 'rm -rf /data/adb/modules/amneziawg' INT TERM EXIT; ");
script.append(String.format("rm -rf /data/adb/modules/amneziawg/; mkdir -p /data/adb/modules/amneziawg%s; ", INSTALL_DIR));
script.append("printf 'id=amneziawg\nname=AmneziaWG Command Line Tools\nversion=1.0\nversionCode=1\nauthor=amnezia\ndescription=Command line tools for AmneziaWG\nminMagisk=1500\n' > /data/adb/modules/amneziawg/module.prop; ");
script.append("touch /data/adb/modules/amneziawg/auto_mount; ");
script.append("trap 'rm -rf /data/adb/modules/wireguard' INT TERM EXIT; ");
script.append(String.format("rm -rf /data/adb/modules/wireguard/; mkdir -p /data/adb/modules/wireguard%s; ", INSTALL_DIR));
script.append("printf 'id=wireguard\nname=WireGuard Command Line Tools\nversion=1.0\nversionCode=1\nauthor=zx2c4\ndescription=Command line tools for WireGuard\nminMagisk=1500\n' > /data/adb/modules/wireguard/module.prop; ");
script.append("touch /data/adb/modules/wireguard/auto_mount; ");
for (final String name : EXECUTABLES) {
final File destination = new File("/data/adb/modules/amneziawg" + INSTALL_DIR, name);
final File destination = new File("/data/adb/modules/wireguard" + INSTALL_DIR, name);
script.append(String.format("cp '%s' '%s'; chmod 755 '%s'; chcon 'u:object_r:system_file:s0' '%s' || true; ",
new File(localBinaryDir, name), destination, destination, destination));
}
@@ -1,11 +1,11 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.config;
package com.wireguard.config;
import org.amnezia.awg.util.NonNullForAll;
import com.wireguard.util.NonNullForAll;
import java.util.Iterator;
import java.util.Optional;
@@ -14,7 +14,7 @@ import java.util.regex.Pattern;
@NonNullForAll
public final class Attribute {
private static final Pattern LINE_PATTERN = Pattern.compile("(\\w+)\\s*=\\s*(.*?)\\s*$");
private static final Pattern LINE_PATTERN = Pattern.compile("(\\w+)\\s*=\\s*([^\\s#][^#]*)");
private static final Pattern LIST_SEPARATOR = Pattern.compile("\\s*,\\s*");
private final String key;
@@ -1,12 +1,12 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.config;
package com.wireguard.config;
import org.amnezia.awg.crypto.KeyFormatException;
import org.amnezia.awg.util.NonNullForAll;
import com.wireguard.crypto.KeyFormatException;
import com.wireguard.util.NonNullForAll;
import androidx.annotation.Nullable;
@@ -78,23 +78,7 @@ public class BadConfigException extends Exception {
PERSISTENT_KEEPALIVE("PersistentKeepalive"),
PRE_SHARED_KEY("PresharedKey"),
PRIVATE_KEY("PrivateKey"),
PUBLIC_KEY("PublicKey"),
JUNK_PACKET_COUNT("JunkPacketCount"),
JUNK_PACKET_MIN_SIZE("JunkPacketMinSize"),
JUNK_PACKET_MAX_SIZE("JunkPacketMaxSize"),
INIT_PACKET_JUNK_SIZE("InitPacketJunkSize"),
RESPONSE_PACKET_JUNK_SIZE("ResponsePacketJunkSize"),
COOKIE_REPLY_PACKET_JUNK_SIZE("CookieReplyPacketJunkSize"),
TRANSPORT_PACKET_JUNK_SIZE("TransportPacketJunkSize"),
INIT_PACKET_MAGIC_HEADER("InitPacketMagicHeader"),
RESPONSE_PACKET_MAGIC_HEADER("ResponsePacketMagicHeader"),
UNDERLOAD_PACKET_MAGIC_HEADER("UnderloadPacketMagicHeader"),
TRANSPORT_PACKET_MAGIC_HEADER("TransportPacketMagicHeader"),
SPECIAL_JUNK_I1("SpecialJunkI1"),
SPECIAL_JUNK_I2("SpecialJunkI2"),
SPECIAL_JUNK_I3("SpecialJunkI3"),
SPECIAL_JUNK_I4("SpecialJunkI4"),
SPECIAL_JUNK_I5("SpecialJunkI5");
PUBLIC_KEY("PublicKey");
private final String name;
@@ -1,14 +1,14 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.config;
package com.wireguard.config;
import org.amnezia.awg.config.BadConfigException.Location;
import org.amnezia.awg.config.BadConfigException.Reason;
import org.amnezia.awg.config.BadConfigException.Section;
import org.amnezia.awg.util.NonNullForAll;
import com.wireguard.config.BadConfigException.Location;
import com.wireguard.config.BadConfigException.Reason;
import com.wireguard.config.BadConfigException.Section;
import com.wireguard.util.NonNullForAll;
import java.io.BufferedReader;
import java.io.IOException;
@@ -23,7 +23,7 @@ import java.util.Objects;
import androidx.annotation.Nullable;
/**
* Represents the contents of a awg-quick configuration file, made up of one or more "Interface"
* Represents the contents of a wg-quick configuration file, made up of one or more "Interface"
* sections (combined together), and zero or more "Peer" sections (treated individually).
* <p>
* Instances of this class are immutable.
@@ -44,7 +44,7 @@ public final class Config {
* {@link BadConfigException} if the input is not well-formed or contains data that cannot
* be parsed.
*
* @param stream a stream of UTF-8 text that is interpreted as an AmneziaWG configuration
* @param stream a stream of UTF-8 text that is interpreted as a WireGuard configuration
* @return a {@code Config} instance representing the supplied configuration
*/
public static Config parse(final InputStream stream)
@@ -57,7 +57,7 @@ public final class Config {
* {@link BadConfigException} if the input is not well-formed or contains data that cannot
* be parsed.
*
* @param reader a BufferedReader of UTF-8 text that is interpreted as an AmneziaWG configuration
* @param reader a BufferedReader of UTF-8 text that is interpreted as a WireGuard configuration
* @return a {@code Config} instance representing the supplied configuration
*/
public static Config parse(final BufferedReader reader)
@@ -155,30 +155,30 @@ public final class Config {
}
/**
* Converts the {@code Config} into a string suitable for use as a {@code awg-quick}
* Converts the {@code Config} into a string suitable for use as a {@code wg-quick}
* configuration file.
*
* @return the {@code Config} represented as one [Interface] and zero or more [Peer] sections
*/
public String toAwgQuickString() {
public String toWgQuickString() {
final StringBuilder sb = new StringBuilder();
sb.append("[Interface]\n").append(interfaze.toAwgQuickString());
sb.append("[Interface]\n").append(interfaze.toWgQuickString());
for (final Peer peer : peers)
sb.append("\n[Peer]\n").append(peer.toAwgQuickString());
sb.append("\n[Peer]\n").append(peer.toWgQuickString());
return sb.toString();
}
/**
* Serializes the {@code Config} for use with the AmneziaWG cross-platform userspace API.
* Serializes the {@code Config} for use with the WireGuard cross-platform userspace API.
*
* @return the {@code Config} represented as a series of "key=value" lines
*/
public String toAwgUserspaceString() {
public String toWgUserspaceString() {
final StringBuilder sb = new StringBuilder();
sb.append(interfaze.toAwgUserspaceString());
sb.append(interfaze.toWgUserspaceString());
sb.append("replace_peers=true\n");
for (final Peer peer : peers)
sb.append(peer.toAwgUserspaceString());
sb.append(peer.toWgUserspaceString());
return sb.toString();
}
@@ -1,11 +1,11 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.config;
package com.wireguard.config;
import org.amnezia.awg.util.NonNullForAll;
import com.wireguard.util.NonNullForAll;
import java.lang.reflect.Method;
import java.net.Inet4Address;
@@ -1,11 +1,11 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.config;
package com.wireguard.config;
import org.amnezia.awg.util.NonNullForAll;
import com.wireguard.util.NonNullForAll;
import java.net.Inet4Address;
import java.net.InetAddress;
@@ -21,7 +21,7 @@ import androidx.annotation.Nullable;
/**
* An external endpoint (host and port) used to connect to an AmneziaWG {@link Peer}.
* An external endpoint (host and port) used to connect to a WireGuard {@link Peer}.
* <p>
* Instances of this class are externally immutable.
*/
@@ -48,7 +48,7 @@ public final class InetEndpoint {
throw new ParseException(InetEndpoint.class, endpoint, "Forbidden characters");
final URI uri;
try {
uri = new URI("awg://" + endpoint);
uri = new URI("wg://" + endpoint);
} catch (final URISyntaxException e) {
throw new ParseException(InetEndpoint.class, endpoint, e);
}
@@ -1,11 +1,11 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.config;
package com.wireguard.config;
import org.amnezia.awg.util.NonNullForAll;
import com.wireguard.util.NonNullForAll;
import java.net.Inet4Address;
import java.net.InetAddress;
@@ -0,0 +1,423 @@
/*
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package com.wireguard.config;
import com.wireguard.config.BadConfigException.Location;
import com.wireguard.config.BadConfigException.Reason;
import com.wireguard.config.BadConfigException.Section;
import com.wireguard.crypto.Key;
import com.wireguard.crypto.KeyFormatException;
import com.wireguard.crypto.KeyPair;
import com.wireguard.util.NonNullForAll;
import java.net.InetAddress;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import androidx.annotation.Nullable;
/**
* Represents the configuration for a WireGuard interface (an [Interface] block). Interfaces must
* have a private key (used to initialize a {@code KeyPair}), and may optionally have several other
* attributes.
* <p>
* Instances of this class are immutable.
*/
@NonNullForAll
public final class Interface {
private static final int MAX_UDP_PORT = 65535;
private static final int MIN_UDP_PORT = 0;
private final Set<InetNetwork> addresses;
private final Set<InetAddress> dnsServers;
private final Set<String> dnsSearchDomains;
private final Set<String> excludedApplications;
private final Set<String> includedApplications;
private final KeyPair keyPair;
private final Optional<Integer> listenPort;
private final Optional<Integer> mtu;
private Interface(final Builder builder) {
// Defensively copy to ensure immutability even if the Builder is reused.
addresses = Collections.unmodifiableSet(new LinkedHashSet<>(builder.addresses));
dnsServers = Collections.unmodifiableSet(new LinkedHashSet<>(builder.dnsServers));
dnsSearchDomains = Collections.unmodifiableSet(new LinkedHashSet<>(builder.dnsSearchDomains));
excludedApplications = Collections.unmodifiableSet(new LinkedHashSet<>(builder.excludedApplications));
includedApplications = Collections.unmodifiableSet(new LinkedHashSet<>(builder.includedApplications));
keyPair = Objects.requireNonNull(builder.keyPair, "Interfaces must have a private key");
listenPort = builder.listenPort;
mtu = builder.mtu;
}
/**
* Parses an series of "KEY = VALUE" lines into an {@code Interface}. Throws
* {@link ParseException} if the input is not well-formed or contains unknown attributes.
*
* @param lines An iterable sequence of lines, containing at least a private key attribute
* @return An {@code Interface} with all of the attributes from {@code lines} set
*/
public static Interface parse(final Iterable<? extends CharSequence> lines)
throws BadConfigException {
final Builder builder = new Builder();
for (final CharSequence line : lines) {
final Attribute attribute = Attribute.parse(line).orElseThrow(() ->
new BadConfigException(Section.INTERFACE, Location.TOP_LEVEL,
Reason.SYNTAX_ERROR, line));
switch (attribute.getKey().toLowerCase(Locale.ENGLISH)) {
case "address":
builder.parseAddresses(attribute.getValue());
break;
case "dns":
builder.parseDnsServers(attribute.getValue());
break;
case "excludedapplications":
builder.parseExcludedApplications(attribute.getValue());
break;
case "includedapplications":
builder.parseIncludedApplications(attribute.getValue());
break;
case "listenport":
builder.parseListenPort(attribute.getValue());
break;
case "mtu":
builder.parseMtu(attribute.getValue());
break;
case "privatekey":
builder.parsePrivateKey(attribute.getValue());
break;
default:
throw new BadConfigException(Section.INTERFACE, Location.TOP_LEVEL,
Reason.UNKNOWN_ATTRIBUTE, attribute.getKey());
}
}
return builder.build();
}
@Override
public boolean equals(final Object obj) {
if (!(obj instanceof Interface))
return false;
final Interface other = (Interface) obj;
return addresses.equals(other.addresses)
&& dnsServers.equals(other.dnsServers)
&& dnsSearchDomains.equals(other.dnsSearchDomains)
&& excludedApplications.equals(other.excludedApplications)
&& includedApplications.equals(other.includedApplications)
&& keyPair.equals(other.keyPair)
&& listenPort.equals(other.listenPort)
&& mtu.equals(other.mtu);
}
/**
* Returns the set of IP addresses assigned to the interface.
*
* @return a set of {@link InetNetwork}s
*/
public Set<InetNetwork> getAddresses() {
// The collection is already immutable.
return addresses;
}
/**
* Returns the set of DNS servers associated with the interface.
*
* @return a set of {@link InetAddress}es
*/
public Set<InetAddress> getDnsServers() {
// The collection is already immutable.
return dnsServers;
}
/**
* Returns the set of DNS search domains associated with the interface.
*
* @return a set of strings
*/
public Set<String> getDnsSearchDomains() {
// The collection is already immutable.
return dnsSearchDomains;
}
/**
* Returns the set of applications excluded from using the interface.
*
* @return a set of package names
*/
public Set<String> getExcludedApplications() {
// The collection is already immutable.
return excludedApplications;
}
/**
* Returns the set of applications included exclusively for using the interface.
*
* @return a set of package names
*/
public Set<String> getIncludedApplications() {
// The collection is already immutable.
return includedApplications;
}
/**
* Returns the public/private key pair used by the interface.
*
* @return a key pair
*/
public KeyPair getKeyPair() {
return keyPair;
}
/**
* Returns the UDP port number that the WireGuard interface will listen on.
*
* @return a UDP port number, or {@code Optional.empty()} if none is configured
*/
public Optional<Integer> getListenPort() {
return listenPort;
}
/**
* Returns the MTU used for the WireGuard interface.
*
* @return the MTU, or {@code Optional.empty()} if none is configured
*/
public Optional<Integer> getMtu() {
return mtu;
}
@Override
public int hashCode() {
int hash = 1;
hash = 31 * hash + addresses.hashCode();
hash = 31 * hash + dnsServers.hashCode();
hash = 31 * hash + excludedApplications.hashCode();
hash = 31 * hash + includedApplications.hashCode();
hash = 31 * hash + keyPair.hashCode();
hash = 31 * hash + listenPort.hashCode();
hash = 31 * hash + mtu.hashCode();
return hash;
}
/**
* Converts the {@code Interface} into a string suitable for debugging purposes. The {@code
* Interface} is identified by its public key and (if set) the port used for its UDP socket.
*
* @return A concise single-line identifier for the {@code Interface}
*/
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("(Interface ");
sb.append(keyPair.getPublicKey().toBase64());
listenPort.ifPresent(lp -> sb.append(" @").append(lp));
sb.append(')');
return sb.toString();
}
/**
* Converts the {@code Interface} into a string suitable for inclusion in a {@code wg-quick}
* configuration file.
*
* @return The {@code Interface} represented as a series of "Key = Value" lines
*/
public String toWgQuickString() {
final StringBuilder sb = new StringBuilder();
if (!addresses.isEmpty())
sb.append("Address = ").append(Attribute.join(addresses)).append('\n');
if (!dnsServers.isEmpty()) {
final List<String> dnsServerStrings = dnsServers.stream().map(InetAddress::getHostAddress).collect(Collectors.toList());
dnsServerStrings.addAll(dnsSearchDomains);
sb.append("DNS = ").append(Attribute.join(dnsServerStrings)).append('\n');
}
if (!excludedApplications.isEmpty())
sb.append("ExcludedApplications = ").append(Attribute.join(excludedApplications)).append('\n');
if (!includedApplications.isEmpty())
sb.append("IncludedApplications = ").append(Attribute.join(includedApplications)).append('\n');
listenPort.ifPresent(lp -> sb.append("ListenPort = ").append(lp).append('\n'));
mtu.ifPresent(m -> sb.append("MTU = ").append(m).append('\n'));
sb.append("PrivateKey = ").append(keyPair.getPrivateKey().toBase64()).append('\n');
return sb.toString();
}
/**
* Serializes the {@code Interface} for use with the WireGuard cross-platform userspace API.
* Note that not all attributes are included in this representation.
*
* @return the {@code Interface} represented as a series of "KEY=VALUE" lines
*/
public String toWgUserspaceString() {
final StringBuilder sb = new StringBuilder();
sb.append("private_key=").append(keyPair.getPrivateKey().toHex()).append('\n');
listenPort.ifPresent(lp -> sb.append("listen_port=").append(lp).append('\n'));
return sb.toString();
}
@SuppressWarnings("UnusedReturnValue")
public static final class Builder {
// Defaults to an empty set.
private final Set<InetNetwork> addresses = new LinkedHashSet<>();
// Defaults to an empty set.
private final Set<InetAddress> dnsServers = new LinkedHashSet<>();
// Defaults to an empty set.
private final Set<String> dnsSearchDomains = new LinkedHashSet<>();
// Defaults to an empty set.
private final Set<String> excludedApplications = new LinkedHashSet<>();
// Defaults to an empty set.
private final Set<String> includedApplications = new LinkedHashSet<>();
// No default; must be provided before building.
@Nullable private KeyPair keyPair;
// Defaults to not present.
private Optional<Integer> listenPort = Optional.empty();
// Defaults to not present.
private Optional<Integer> mtu = Optional.empty();
public Builder addAddress(final InetNetwork address) {
addresses.add(address);
return this;
}
public Builder addAddresses(final Collection<InetNetwork> addresses) {
this.addresses.addAll(addresses);
return this;
}
public Builder addDnsServer(final InetAddress dnsServer) {
dnsServers.add(dnsServer);
return this;
}
public Builder addDnsServers(final Collection<? extends InetAddress> dnsServers) {
this.dnsServers.addAll(dnsServers);
return this;
}
public Builder addDnsSearchDomain(final String dnsSearchDomain) {
dnsSearchDomains.add(dnsSearchDomain);
return this;
}
public Builder addDnsSearchDomains(final Collection<String> dnsSearchDomains) {
this.dnsSearchDomains.addAll(dnsSearchDomains);
return this;
}
public Interface build() throws BadConfigException {
if (keyPair == null)
throw new BadConfigException(Section.INTERFACE, Location.PRIVATE_KEY,
Reason.MISSING_ATTRIBUTE, null);
if (!includedApplications.isEmpty() && !excludedApplications.isEmpty())
throw new BadConfigException(Section.INTERFACE, Location.INCLUDED_APPLICATIONS,
Reason.INVALID_KEY, null);
return new Interface(this);
}
public Builder excludeApplication(final String application) {
excludedApplications.add(application);
return this;
}
public Builder excludeApplications(final Collection<String> applications) {
excludedApplications.addAll(applications);
return this;
}
public Builder includeApplication(final String application) {
includedApplications.add(application);
return this;
}
public Builder includeApplications(final Collection<String> applications) {
includedApplications.addAll(applications);
return this;
}
public Builder parseAddresses(final CharSequence addresses) throws BadConfigException {
try {
for (final String address : Attribute.split(addresses))
addAddress(InetNetwork.parse(address));
return this;
} catch (final ParseException e) {
throw new BadConfigException(Section.INTERFACE, Location.ADDRESS, e);
}
}
public Builder parseDnsServers(final CharSequence dnsServers) throws BadConfigException {
try {
for (final String dnsServer : Attribute.split(dnsServers)) {
try {
addDnsServer(InetAddresses.parse(dnsServer));
} catch (final ParseException e) {
if (e.getParsingClass() != InetAddress.class || !InetAddresses.isHostname(dnsServer))
throw e;
addDnsSearchDomain(dnsServer);
}
}
return this;
} catch (final ParseException e) {
throw new BadConfigException(Section.INTERFACE, Location.DNS, e);
}
}
public Builder parseExcludedApplications(final CharSequence apps) {
return excludeApplications(List.of(Attribute.split(apps)));
}
public Builder parseIncludedApplications(final CharSequence apps) {
return includeApplications(List.of(Attribute.split(apps)));
}
public Builder parseListenPort(final String listenPort) throws BadConfigException {
try {
return setListenPort(Integer.parseInt(listenPort));
} catch (final NumberFormatException e) {
throw new BadConfigException(Section.INTERFACE, Location.LISTEN_PORT, listenPort, e);
}
}
public Builder parseMtu(final String mtu) throws BadConfigException {
try {
return setMtu(Integer.parseInt(mtu));
} catch (final NumberFormatException e) {
throw new BadConfigException(Section.INTERFACE, Location.MTU, mtu, e);
}
}
public Builder parsePrivateKey(final String privateKey) throws BadConfigException {
try {
return setKeyPair(new KeyPair(Key.fromBase64(privateKey)));
} catch (final KeyFormatException e) {
throw new BadConfigException(Section.INTERFACE, Location.PRIVATE_KEY, e);
}
}
public Builder setKeyPair(final KeyPair keyPair) {
this.keyPair = keyPair;
return this;
}
public Builder setListenPort(final int listenPort) throws BadConfigException {
if (listenPort < MIN_UDP_PORT || listenPort > MAX_UDP_PORT)
throw new BadConfigException(Section.INTERFACE, Location.LISTEN_PORT,
Reason.INVALID_VALUE, String.valueOf(listenPort));
this.listenPort = listenPort == 0 ? Optional.empty() : Optional.of(listenPort);
return this;
}
public Builder setMtu(final int mtu) throws BadConfigException {
if (mtu < 0)
throw new BadConfigException(Section.INTERFACE, Location.LISTEN_PORT,
Reason.INVALID_VALUE, String.valueOf(mtu));
this.mtu = mtu == 0 ? Optional.empty() : Optional.of(mtu);
return this;
}
}
}
@@ -1,11 +1,11 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.config;
package com.wireguard.config;
import org.amnezia.awg.util.NonNullForAll;
import com.wireguard.util.NonNullForAll;
import androidx.annotation.Nullable;
@@ -1,16 +1,16 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.config;
package com.wireguard.config;
import org.amnezia.awg.config.BadConfigException.Location;
import org.amnezia.awg.config.BadConfigException.Reason;
import org.amnezia.awg.config.BadConfigException.Section;
import org.amnezia.awg.crypto.Key;
import org.amnezia.awg.crypto.KeyFormatException;
import org.amnezia.awg.util.NonNullForAll;
import com.wireguard.config.BadConfigException.Location;
import com.wireguard.config.BadConfigException.Reason;
import com.wireguard.config.BadConfigException.Section;
import com.wireguard.crypto.Key;
import com.wireguard.crypto.KeyFormatException;
import com.wireguard.util.NonNullForAll;
import java.util.Collection;
import java.util.Collections;
@@ -23,7 +23,7 @@ import java.util.Set;
import androidx.annotation.Nullable;
/**
* Represents the configuration for an AmneziaWG peer (a [Peer] block). Peers must have a public key,
* Represents the configuration for a WireGuard peer (a [Peer] block). Peers must have a public key,
* and may optionally have several other attributes.
* <p>
* Instances of this class are immutable.
@@ -168,12 +168,12 @@ public final class Peer {
}
/**
* Converts the {@code Peer} into a string suitable for inclusion in a {@code awg-quick}
* Converts the {@code Peer} into a string suitable for inclusion in a {@code wg-quick}
* configuration file.
*
* @return the {@code Peer} represented as a series of "Key = Value" lines
*/
public String toAwgQuickString() {
public String toWgQuickString() {
final StringBuilder sb = new StringBuilder();
if (!allowedIps.isEmpty())
sb.append("AllowedIPs = ").append(Attribute.join(allowedIps)).append('\n');
@@ -185,12 +185,12 @@ public final class Peer {
}
/**
* Serializes the {@code Peer} for use with the AmneziaWG cross-platform userspace API. Note
* Serializes the {@code Peer} for use with the WireGuard cross-platform userspace API. Note
* that not all attributes are included in this representation.
*
* @return the {@code Peer} represented as a series of "key=value" lines
*/
public String toAwgUserspaceString() {
public String toWgUserspaceString() {
final StringBuilder sb = new StringBuilder();
// The order here is important: public_key signifies the beginning of a new peer.
sb.append("public_key=").append(publicKey.toHex()).append('\n');
@@ -204,7 +204,7 @@ public final class Peer {
@SuppressWarnings("UnusedReturnValue")
public static final class Builder {
// See awg(8)
// See wg(8)
private static final int MAX_PERSISTENT_KEEPALIVE = 65535;
// Defaults to an empty set.
@@ -1,12 +1,12 @@
/*
* Copyright © 2016 Southern Storm Software, Pty Ltd.
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.crypto;
package com.wireguard.crypto;
import org.amnezia.awg.util.NonNullForAll;
import com.wireguard.util.NonNullForAll;
import java.util.Arrays;
@@ -15,7 +15,7 @@ import androidx.annotation.Nullable;
/**
* Implementation of Curve25519 ECDH.
* <p>
* This implementation was imported to AmneziaWG from noise-java:
* This implementation was imported to WireGuard from noise-java:
* https://github.com/rweather/noise-java
* <p>
* This implementation is based on that from arduinolibs:
@@ -1,19 +1,19 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.crypto;
package com.wireguard.crypto;
import org.amnezia.awg.crypto.KeyFormatException.Type;
import org.amnezia.awg.util.NonNullForAll;
import com.wireguard.crypto.KeyFormatException.Type;
import com.wireguard.util.NonNullForAll;
import java.security.MessageDigest;
import java.security.SecureRandom;
import java.util.Arrays;
/**
* Represents an AmneziaWG public or private key. This class uses specialized constant-time base64
* Represents a WireGuard public or private key. This class uses specialized constant-time base64
* and hexadecimal codec implementations that resist side-channel attacks.
* <p>
* Instances of this class are immutable.
@@ -83,10 +83,10 @@ public final class Key {
}
/**
* Decodes an AmneziaWG public or private key from its base64 string representation. This
* Decodes a WireGuard public or private key from its base64 string representation. This
* function throws a {@link KeyFormatException} if the source string is not well-formed.
*
* @param str the base64 string representation of an AmneziaWG key
* @param str the base64 string representation of a WireGuard key
* @return the decoded key encapsulated in an immutable container
*/
public static Key fromBase64(final String str) throws KeyFormatException {
@@ -120,10 +120,10 @@ public final class Key {
}
/**
* Wraps an AmneziaWG public or private key in an immutable container. This function throws a
* Wraps a WireGuard public or private key in an immutable container. This function throws a
* {@link KeyFormatException} if the source data is not the correct length.
*
* @param bytes an array of bytes containing an AmneziaWG key in binary format
* @param bytes an array of bytes containing a WireGuard key in binary format
* @return the key encapsulated in an immutable container
*/
public static Key fromBytes(final byte[] bytes) throws KeyFormatException {
@@ -133,10 +133,10 @@ public final class Key {
}
/**
* Decodes an AmneziaWG public or private key from its hexadecimal string representation. This
* Decodes a WireGuard public or private key from its hexadecimal string representation. This
* function throws a {@link KeyFormatException} if the source string is not well-formed.
*
* @param str the hexadecimal string representation of an AmneziaWG key
* @param str the hexadecimal string representation of a WireGuard key
* @return the decoded key encapsulated in an immutable container
*/
public static Key fromHex(final String str) throws KeyFormatException {
@@ -269,7 +269,7 @@ public final class Key {
}
/**
* The supported formats for encoding an AmneziaWG key.
* The supported formats for encoding a WireGuard key.
*/
public enum Format {
BASE64(44),
@@ -1,11 +1,11 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.crypto;
package com.wireguard.crypto;
import org.amnezia.awg.util.NonNullForAll;
import com.wireguard.util.NonNullForAll;
/**
* An exception thrown when attempting to parse an invalid key (too short, too long, or byte
@@ -1,14 +1,14 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.crypto;
package com.wireguard.crypto;
import org.amnezia.awg.util.NonNullForAll;
import com.wireguard.util.NonNullForAll;
/**
* Represents a Curve25519 key pair as used by AmneziaWG.
* Represents a Curve25519 key pair as used by WireGuard.
* <p>
* Instances of this class are immutable.
*/
@@ -1,9 +1,9 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.util;
package com.wireguard.util;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
@@ -1,18 +0,0 @@
package org.amnezia.awg;
import androidx.annotation.Nullable;
public class GoBackend {
@Nullable
public static native String awgGetConfig(int handle);
public static native int awgGetSocketV4(int handle);
public static native int awgGetSocketV6(int handle);
public static native void awgTurnOff(int handle);
public static native int awgTurnOn(String ifName, int tunFd, String settings);
public static native String awgVersion();
}
@@ -1,14 +0,0 @@
package org.amnezia.awg.backend;
/**
* Callback for status changes detected by the status polling job.
*/
public interface StatusCallback {
/**
* Called when connection status is determined.
*
* @param connected true if handshake was successful (connected), false if disconnected
*/
void onStatusChanged(boolean connected);
}
File diff suppressed because it is too large Load Diff
@@ -1,13 +1,13 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.config;
package com.wireguard.config;
import org.amnezia.awg.config.BadConfigException.Location;
import org.amnezia.awg.config.BadConfigException.Reason;
import org.amnezia.awg.config.BadConfigException.Section;
import com.wireguard.config.BadConfigException.Location;
import com.wireguard.config.BadConfigException.Reason;
import com.wireguard.config.BadConfigException.Section;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -1,9 +1,9 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.config;
package com.wireguard.config;
import org.junit.Test;
+7 -7
View File
@@ -1,23 +1,23 @@
# SPDX-License-Identifier: Apache-2.0
#
# Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
# Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
cmake_minimum_required(VERSION 3.4.1)
project("AmneziaWG")
project("WireGuard")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
add_link_options(LINKER:--build-id=none)
add_compile_options(-Wall -Werror)
add_executable(libwg-quick.so amneziawg-tools/src/wg-quick/android.c ndk-compat/compat.c)
target_compile_options(libwg-quick.so PUBLIC -std=gnu11 -include ${CMAKE_CURRENT_SOURCE_DIR}/ndk-compat/compat.h -DAWG_PACKAGE_NAME=\"${ANDROID_PACKAGE_NAME}\")
add_executable(libwg-quick.so wireguard-tools/src/wg-quick/android.c ndk-compat/compat.c)
target_compile_options(libwg-quick.so PUBLIC -std=gnu11 -include ${CMAKE_CURRENT_SOURCE_DIR}/ndk-compat/compat.h -DWG_PACKAGE_NAME=\"${ANDROID_PACKAGE_NAME}\")
target_link_libraries(libwg-quick.so -ldl)
file(GLOB WG_SOURCES amneziawg-tools/src/*.c ndk-compat/compat.c)
file(GLOB WG_SOURCES wireguard-tools/src/*.c ndk-compat/compat.c)
add_executable(libwg.so ${WG_SOURCES})
target_include_directories(libwg.so PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/amneziawg-tools/src/uapi/linux/" "${CMAKE_CURRENT_SOURCE_DIR}/amneziawg-tools/src/")
target_include_directories(libwg.so PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/wireguard-tools/src/uapi/linux/" "${CMAKE_CURRENT_SOURCE_DIR}/wireguard-tools/src/")
target_compile_options(libwg.so PUBLIC -std=gnu11 -include ${CMAKE_CURRENT_SOURCE_DIR}/ndk-compat/compat.h -DRUNSTATEDIR=\"/data/data/${ANDROID_PACKAGE_NAME}/cache\")
add_custom_target(libwg-go.so WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/libwg-go" COMMENT "Building amneziawg-go" VERBATIM COMMAND "${ANDROID_HOST_PREBUILTS}/bin/make"
add_custom_target(libwg-go.so WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/libwg-go" COMMENT "Building wireguard-go" VERBATIM COMMAND "${ANDROID_HOST_PREBUILTS}/bin/make"
ANDROID_ARCH_NAME=${ANDROID_ARCH_NAME}
ANDROID_PACKAGE_NAME=${ANDROID_PACKAGE_NAME}
GRADLE_USER_HOME=${GRADLE_USER_HOME}
+6 -6
View File
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
#
# Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
# Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
BUILDDIR ?= $(CURDIR)/build
DESTDIR ?= $(CURDIR)/out
@@ -20,12 +20,12 @@ export GOARCH := $(NDK_GO_ARCH_MAP_$(ANDROID_ARCH_NAME))
export GOOS := android
export CGO_ENABLED := 1
GO_VERSION := 1.24.2
GO_VERSION := 1.24.3
GO_PLATFORM := $(shell uname -s | tr '[:upper:]' '[:lower:]')-$(NDK_GO_ARCH_MAP_$(shell uname -m))
GO_TARBALL := go$(GO_VERSION).$(GO_PLATFORM).tar.gz
GO_HASH_darwin-amd64 := 238d9c065d09ff6af229d2e3b8b5e85e688318d69f4006fb85a96e41c216ea83
GO_HASH_darwin-arm64 := b70f8b3c5b4ccb0ad4ffa5ee91cd38075df20fdbd953a1daedd47f50fbcff47a
GO_HASH_linux-amd64 := 68097bd680839cbc9d464a0edce4f7c333975e27a90246890e9f1078c7e702ad
GO_HASH_darwin-amd64 := 13e6fe3fcf65689d77d40e633de1e31c6febbdbcb846eb05fc2434ed2213e92b
GO_HASH_darwin-arm64 := 64a3fa22142f627e78fac3018ce3d4aeace68b743eff0afda8aae0411df5e4fb
GO_HASH_linux-amd64 := 3333f6ea53afa971e9078895eaa4ac7204a8c6b5c68c10e6bc9a33e8e391bdd8
default: $(DESTDIR)/libwg-go.so
@@ -47,6 +47,6 @@ $(BUILDDIR)/go-$(GO_VERSION)/.prepared: $(GRADLE_USER_HOME)/caches/golang/$(GO_T
$(DESTDIR)/libwg-go.so: export PATH := $(BUILDDIR)/go-$(GO_VERSION)/bin/:$(PATH)
$(DESTDIR)/libwg-go.so: $(BUILDDIR)/go-$(GO_VERSION)/.prepared go.mod
go build -tags linux -ldflags="-X github.com/amnezia-vpn/amneziawg-go/ipc.socketDirectory=/data/data/$(ANDROID_PACKAGE_NAME)/cache/amneziawg -buildid=" -v -trimpath -buildvcs=false -o "$@" -buildmode c-shared
go build -tags linux -ldflags="-X golang.zx2c4.com/wireguard/ipc.socketDirectory=/data/data/$(ANDROID_PACKAGE_NAME)/cache/wireguard -buildid=" -v -trimpath -buildvcs=false -o "$@" -buildmode c-shared
.DELETE_ON_ERROR:
+19 -19
View File
@@ -20,11 +20,11 @@ import (
"strings"
"unsafe"
"github.com/amnezia-vpn/amneziawg-go/conn"
"github.com/amnezia-vpn/amneziawg-go/device"
"github.com/amnezia-vpn/amneziawg-go/ipc"
"github.com/amnezia-vpn/amneziawg-go/tun"
"golang.org/x/sys/unix"
"golang.zx2c4.com/wireguard/conn"
"golang.zx2c4.com/wireguard/device"
"golang.zx2c4.com/wireguard/ipc"
"golang.zx2c4.com/wireguard/tun"
)
type AndroidLogger struct {
@@ -66,15 +66,15 @@ func init() {
n--
}
buf[n] = 0
C.__android_log_write(C.ANDROID_LOG_ERROR, cstring("AmneziaWG/Stacktrace"), (*C.char)(unsafe.Pointer(&buf[0])))
C.__android_log_write(C.ANDROID_LOG_ERROR, cstring("WireGuard/GoBackend/Stacktrace"), (*C.char)(unsafe.Pointer(&buf[0])))
}
}
}()
}
//export awgTurnOn
func awgTurnOn(interfaceName string, tunFd int32, settings string) int32 {
tag := cstring("AmneziaWG/" + interfaceName)
//export wgTurnOn
func wgTurnOn(interfaceName string, tunFd int32, settings string) int32 {
tag := cstring("WireGuard/GoBackend/" + interfaceName)
logger := &device.Logger{
Verbosef: AndroidLogger{level: C.ANDROID_LOG_DEBUG, tag: tag}.Printf,
Errorf: AndroidLogger{level: C.ANDROID_LOG_ERROR, tag: tag}.Printf,
@@ -146,8 +146,8 @@ func awgTurnOn(interfaceName string, tunFd int32, settings string) int32 {
return i
}
//export awgTurnOff
func awgTurnOff(tunnelHandle int32) {
//export wgTurnOff
func wgTurnOff(tunnelHandle int32) {
handle, ok := tunnelHandles[tunnelHandle]
if !ok {
return
@@ -159,8 +159,8 @@ func awgTurnOff(tunnelHandle int32) {
handle.device.Close()
}
//export awgGetSocketV4
func awgGetSocketV4(tunnelHandle int32) int32 {
//export wgGetSocketV4
func wgGetSocketV4(tunnelHandle int32) int32 {
handle, ok := tunnelHandles[tunnelHandle]
if !ok {
return -1
@@ -176,8 +176,8 @@ func awgGetSocketV4(tunnelHandle int32) int32 {
return int32(fd)
}
//export awgGetSocketV6
func awgGetSocketV6(tunnelHandle int32) int32 {
//export wgGetSocketV6
func wgGetSocketV6(tunnelHandle int32) int32 {
handle, ok := tunnelHandles[tunnelHandle]
if !ok {
return -1
@@ -193,8 +193,8 @@ func awgGetSocketV6(tunnelHandle int32) int32 {
return int32(fd)
}
//export awgGetConfig
func awgGetConfig(tunnelHandle int32) *C.char {
//export wgGetConfig
func wgGetConfig(tunnelHandle int32) *C.char {
handle, ok := tunnelHandles[tunnelHandle]
if !ok {
return nil
@@ -206,14 +206,14 @@ func awgGetConfig(tunnelHandle int32) *C.char {
return C.CString(settings)
}
//export awgVersion
func awgVersion() *C.char {
//export wgVersion
func wgVersion() *C.char {
info, ok := debug.ReadBuildInfo()
if !ok {
return C.CString("unknown")
}
for _, dep := range info.Deps {
if dep.Path == "github.com/amnezia-vpn/amneziawg-go" {
if dep.Path == "golang.zx2c4.com/wireguard" {
parts := strings.Split(dep.Version, "-")
if len(parts) == 3 && len(parts[2]) == 12 {
return C.CString(parts[2][:7])
+5 -5
View File
@@ -1,14 +1,14 @@
module github.com/amnezia-vpn/amneziawg-android
module golang.zx2c4.com/wireguard/android
go 1.24.4
go 1.23.1
require (
github.com/amnezia-vpn/amneziawg-go v0.2.16
golang.org/x/sys v0.33.0
golang.zx2c4.com/wireguard v0.0.0-20250515145403-1571e0fbae8e
)
require (
golang.org/x/crypto v0.39.0 // indirect
golang.org/x/net v0.41.0 // indirect
golang.org/x/crypto v0.38.0 // indirect
golang.org/x/net v0.40.0 // indirect
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect
)
+14 -14
View File
@@ -1,18 +1,18 @@
github.com/amnezia-vpn/amneziawg-go v0.2.16 h1:XY6HOq/xtqH8ZXMncRWkjFs85EKdN10NLNnw23kTpE0=
github.com/amnezia-vpn/amneziawg-go v0.2.16/go.mod h1:nRkPpIzjCxMW8pZKXTRkpqAQVlmFJdVOGkeQSC7wbms=
github.com/google/btree v1.1.3 h1:CVpQJjYgC4VbzxeGVHfvZrv1ctoYCAI8vbl07Fcxlyg=
github.com/google/btree v1.1.3/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4=
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM=
golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U=
golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw=
golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA=
github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU=
github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4=
golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8=
golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw=
golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY=
golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds=
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/time v0.9.0 h1:EsRrnYcQiGH+5FfbgvV4AP7qEZstoyrHB0DzarOQ4ZY=
golang.org/x/time v0.9.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ=
golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 h1:B82qJJgjvYKsXS9jeunTOisW56dUokqW/FOteYJJ/yg=
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2/go.mod h1:deeaetjYA+DHMHg+sMSMI58GrEteJUUzzw7en6TJQcI=
gvisor.dev/gvisor v0.0.0-20231202080848-1f7806d17489 h1:ze1vwAdliUAr68RQ5NtufWaXaOg8WUO2OACzEV+TNdE=
gvisor.dev/gvisor v0.0.0-20231202080848-1f7806d17489/go.mod h1:10sU+Uh5KKNv1+2x2A0Gvzt8FjD3ASIhorV3YsauXhk=
golang.zx2c4.com/wireguard v0.0.0-20250515144814-842888ac5c93 h1:7ZEIuxqu71NkNE9klltGsEqv3tiXkUHlZ6aapRGhwwg=
golang.zx2c4.com/wireguard v0.0.0-20250515144814-842888ac5c93/go.mod h1:rpwXGsirqLqN2L0JDJQlwOboGHmptD5ZD6T2VmcqhTw=
golang.zx2c4.com/wireguard v0.0.0-20250515145403-1571e0fbae8e h1:ZB5hAWug6qfyDjed7y2uJB6f1ufSJfJok753/GQ1kCA=
golang.zx2c4.com/wireguard v0.0.0-20250515145403-1571e0fbae8e/go.mod h1:rpwXGsirqLqN2L0JDJQlwOboGHmptD5ZD6T2VmcqhTw=
gvisor.dev/gvisor v0.0.0-20250503011706-39ed1f5ac29c h1:m/r7OM+Y2Ty1sgBQ7Qb27VgIMBW8ZZhT4gLnUyDIhzI=
gvisor.dev/gvisor v0.0.0-20250503011706-39ed1f5ac29c/go.mod h1:3r5CMtNQMKIvBlrmM9xWUNamjKBYPOWyXOjmg5Kts3g=
+18 -18
View File
@@ -8,20 +8,20 @@
#include <string.h>
struct go_string { const char *str; long n; };
extern int awgTurnOn(struct go_string ifname, int tun_fd, struct go_string settings);
extern void awgTurnOff(int handle);
extern int awgGetSocketV4(int handle);
extern int awgGetSocketV6(int handle);
extern char *awgGetConfig(int handle);
extern char *awgVersion();
extern int wgTurnOn(struct go_string ifname, int tun_fd, struct go_string settings);
extern void wgTurnOff(int handle);
extern int wgGetSocketV4(int handle);
extern int wgGetSocketV6(int handle);
extern char *wgGetConfig(int handle);
extern char *wgVersion();
JNIEXPORT jint JNICALL Java_org_amnezia_awg_GoBackend_awgTurnOn(JNIEnv *env, jclass c, jstring ifname, jint tun_fd, jstring settings)
JNIEXPORT jint JNICALL Java_com_wireguard_android_backend_GoBackend_wgTurnOn(JNIEnv *env, jclass c, jstring ifname, jint tun_fd, jstring settings)
{
const char *ifname_str = (*env)->GetStringUTFChars(env, ifname, 0);
size_t ifname_len = (*env)->GetStringUTFLength(env, ifname);
const char *settings_str = (*env)->GetStringUTFChars(env, settings, 0);
size_t settings_len = (*env)->GetStringUTFLength(env, settings);
int ret = awgTurnOn((struct go_string){
int ret = wgTurnOn((struct go_string){
.str = ifname_str,
.n = ifname_len
}, tun_fd, (struct go_string){
@@ -33,25 +33,25 @@ JNIEXPORT jint JNICALL Java_org_amnezia_awg_GoBackend_awgTurnOn(JNIEnv *env, jcl
return ret;
}
JNIEXPORT void JNICALL Java_org_amnezia_awg_GoBackend_awgTurnOff(JNIEnv *env, jclass c, jint handle)
JNIEXPORT void JNICALL Java_com_wireguard_android_backend_GoBackend_wgTurnOff(JNIEnv *env, jclass c, jint handle)
{
awgTurnOff(handle);
wgTurnOff(handle);
}
JNIEXPORT jint JNICALL Java_org_amnezia_awg_GoBackend_awgGetSocketV4(JNIEnv *env, jclass c, jint handle)
JNIEXPORT jint JNICALL Java_com_wireguard_android_backend_GoBackend_wgGetSocketV4(JNIEnv *env, jclass c, jint handle)
{
return awgGetSocketV4(handle);
return wgGetSocketV4(handle);
}
JNIEXPORT jint JNICALL Java_org_amnezia_awg_GoBackend_awgGetSocketV6(JNIEnv *env, jclass c, jint handle)
JNIEXPORT jint JNICALL Java_com_wireguard_android_backend_GoBackend_wgGetSocketV6(JNIEnv *env, jclass c, jint handle)
{
return awgGetSocketV6(handle);
return wgGetSocketV6(handle);
}
JNIEXPORT jstring JNICALL Java_org_amnezia_awg_GoBackend_awgGetConfig(JNIEnv *env, jclass c, jint handle)
JNIEXPORT jstring JNICALL Java_com_wireguard_android_backend_GoBackend_wgGetConfig(JNIEnv *env, jclass c, jint handle)
{
jstring ret;
char *config = awgGetConfig(handle);
char *config = wgGetConfig(handle);
if (!config)
return NULL;
ret = (*env)->NewStringUTF(env, config);
@@ -59,10 +59,10 @@ JNIEXPORT jstring JNICALL Java_org_amnezia_awg_GoBackend_awgGetConfig(JNIEnv *en
return ret;
}
JNIEXPORT jstring JNICALL Java_org_amnezia_awg_GoBackend_awgVersion(JNIEnv *env, jclass c)
JNIEXPORT jstring JNICALL Java_com_wireguard_android_backend_GoBackend_wgVersion(JNIEnv *env, jclass c)
{
jstring ret;
char *version = awgVersion();
char *version = wgVersion();
if (!version)
return NULL;
ret = (*env)->NewStringUTF(env, version);
+1 -1
View File
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: BSD
*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
*
*/
+1 -1
View File
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: BSD
*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
*
*/
+7 -5
View File
@@ -3,7 +3,7 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
val pkg: String = providers.gradleProperty("amneziawgPackageName").get()
val pkg: String = providers.gradleProperty("wireguardPackageName").get()
plugins {
alias(libs.plugins.android.application)
@@ -12,6 +12,7 @@ plugins {
}
android {
compileSdk = 36
buildFeatures {
buildConfig = true
dataBinding = true
@@ -20,9 +21,10 @@ android {
namespace = pkg
defaultConfig {
applicationId = pkg
targetSdk = 35
versionCode = providers.gradleProperty("amneziawgVersionCode").get().toInt()
versionName = providers.gradleProperty("amneziawgVersionName").get()
minSdk = 21
targetSdk = 36
versionCode = providers.gradleProperty("wireguardVersionCode").get().toInt()
versionName = providers.gradleProperty("wireguardVersionName").get()
buildConfigField("int", "MIN_SDK_VERSION", minSdk.toString())
}
compileOptions {
@@ -87,5 +89,5 @@ tasks.withType<JavaCompile>().configureEach {
}
tasks.withType<KotlinCompile>().configureEach {
compilerOptions.jvmTarget.set(JvmTarget.JVM_17)
compilerOptions.jvmTarget = JvmTarget.JVM_17
}
+12 -12
View File
@@ -3,18 +3,18 @@
"names": [
{
"names": [
{ "name": "awg0" },
{ "name": "awg1" },
{ "name": "awg2" },
{ "name": "awg3" },
{ "name": "awg4" },
{ "name": "awg5" },
{ "name": "awg6" },
{ "name": "awg7" },
{ "name": "awg8" },
{ "name": "awg9" },
{ "name": "awg10" },
{ "name": "awg11" }
{ "name": "wg0" },
{ "name": "wg1" },
{ "name": "wg2" },
{ "name": "wg3" },
{ "name": "wg4" },
{ "name": "wg5" },
{ "name": "wg6" },
{ "name": "wg7" },
{ "name": "wg8" },
{ "name": "wg9" },
{ "name": "wg10" },
{ "name": "wg11" }
],
"checked": [
{ "checked": true },
+1 -1
View File
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name" translatable="false">AmneziaWG β</string>
<string name="app_name" translatable="false">WireGuard β</string>
</resources>
+11
View File
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
~ SPDX-License-Identifier: Apache-2.0
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission
android:name="android.permission.REQUEST_INSTALL_PACKAGES"
tools:node="remove" />
</manifest>
+16 -5
View File
@@ -1,12 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
~ SPDX-License-Identifier: Apache-2.0
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:installLocation="internalOnly">
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission
android:name="android.permission.SYSTEM_ALERT_WINDOW"
android:minSdkVersion="34" />
@@ -114,14 +117,22 @@
</intent-filter>
</receiver>
<receiver
android:name=".updater.Updater$AppUpdatedReceiver"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
</intent-filter>
</receiver>
<receiver
android:name=".model.TunnelManager$IntentReceiver"
android:exported="true"
android:permission="${applicationId}.permission.CONTROL_TUNNELS">
<intent-filter>
<action android:name="org.amnezia.awg.action.REFRESH_TUNNEL_STATES" />
<action android:name="org.amnezia.awg.action.SET_TUNNEL_UP" />
<action android:name="org.amnezia.awg.action.SET_TUNNEL_DOWN" />
<action android:name="com.wireguard.android.action.REFRESH_TUNNEL_STATES" />
<action android:name="com.wireguard.android.action.SET_TUNNEL_UP" />
<action android:name="com.wireguard.android.action.SET_TUNNEL_DOWN" />
</intent-filter>
</receiver>
@@ -1,8 +1,8 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg
package com.wireguard.android
import android.content.Context
import android.content.Intent
@@ -17,17 +17,16 @@ import androidx.datastore.preferences.core.PreferenceDataStoreFactory
import androidx.datastore.preferences.core.Preferences
import androidx.datastore.preferences.preferencesDataStoreFile
import com.google.android.material.color.DynamicColors
import org.amnezia.awg.backend.Backend
import org.amnezia.awg.backend.GoBackend
import org.amnezia.awg.backend.AwgQuickBackend
import org.amnezia.awg.configStore.FileConfigStore
import org.amnezia.awg.model.TunnelManager
import org.amnezia.awg.util.NetworkState
import org.amnezia.awg.util.NetworkType
import org.amnezia.awg.util.RootShell
import org.amnezia.awg.util.ToolsInstaller
import org.amnezia.awg.util.UserKnobs
import org.amnezia.awg.util.applicationScope
import com.wireguard.android.backend.Backend
import com.wireguard.android.backend.GoBackend
import com.wireguard.android.backend.WgQuickBackend
import com.wireguard.android.configStore.FileConfigStore
import com.wireguard.android.model.TunnelManager
import com.wireguard.android.updater.Updater
import com.wireguard.android.util.RootShell
import com.wireguard.android.util.ToolsInstaller
import com.wireguard.android.util.UserKnobs
import com.wireguard.android.util.applicationScope
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@@ -49,12 +48,10 @@ class Application : android.app.Application() {
private lateinit var preferencesDataStore: DataStore<Preferences>
private lateinit var toolsInstaller: ToolsInstaller
private lateinit var tunnelManager: TunnelManager
private lateinit var networkState: NetworkState
override fun attachBaseContext(context: Context) {
super.attachBaseContext(context)
if (BuildConfig.MIN_SDK_VERSION > Build.VERSION.SDK_INT) {
@Suppress("UnsafeImplicitIntentLaunch")
val intent = Intent(Intent.ACTION_MAIN)
intent.addCategory(Intent.CATEGORY_HOME)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
@@ -66,14 +63,14 @@ class Application : android.app.Application() {
private suspend fun determineBackend(): Backend {
var backend: Backend? = null
if (UserKnobs.enableKernelModule.first() && AwgQuickBackend.hasKernelSupport()) {
if (UserKnobs.enableKernelModule.first() && WgQuickBackend.hasKernelSupport()) {
try {
rootShell.start()
val awgQuickBackend = AwgQuickBackend(applicationContext, rootShell, toolsInstaller)
awgQuickBackend.setMultipleTunnels(UserKnobs.multipleTunnels.first())
backend = awgQuickBackend
val wgQuickBackend = WgQuickBackend(applicationContext, rootShell, toolsInstaller)
wgQuickBackend.setMultipleTunnels(UserKnobs.multipleTunnels.first())
backend = wgQuickBackend
UserKnobs.multipleTunnels.onEach {
awgQuickBackend.setMultipleTunnels(it)
wgQuickBackend.setMultipleTunnels(it)
}.launchIn(coroutineScope)
} catch (ignored: Exception) {
}
@@ -111,22 +108,15 @@ class Application : android.app.Application() {
}
tunnelManager = TunnelManager(FileConfigStore(applicationContext))
tunnelManager.onCreate()
// Initialize network state monitor for auto-reconnection
networkState = NetworkState(applicationContext) { oldType, newType ->
Log.i(TAG, "NetworkState callback: Network changed: $oldType -> $newType")
onNetworkChange(oldType, newType)
}
coroutineScope.launch(Dispatchers.IO) {
try {
backend = determineBackend()
futureBackend.complete(backend!!)
networkState.bindNetworkListener()
} catch (e: Throwable) {
Log.e(TAG, Log.getStackTraceString(e))
}
}
Updater.monitorForUpdates()
if (BuildConfig.DEBUG) {
StrictMode.setVmPolicy(VmPolicy.Builder().detectAll().penaltyLog().build())
@@ -135,58 +125,13 @@ class Application : android.app.Application() {
}
override fun onTerminate() {
networkState.unbindNetworkListener()
coroutineScope.cancel()
super.onTerminate()
}
/**
* Called when network changes (e.g., WiFi to Mobile or vice versa).
* Reconnects active tunnels to ensure VPN connection works on new network.
*/
private fun onNetworkChange(oldType: NetworkType, newType: NetworkType) {
Log.i(TAG, "onNetworkChange called: $oldType -> $newType")
if (newType == NetworkType.NONE) {
Log.i(TAG, "Network lost, waiting for new connection...")
return
}
coroutineScope.launch {
try {
val activeTunnels = tunnelManager.getTunnels().filter {
it.state == org.amnezia.awg.backend.Tunnel.State.UP
}
if (activeTunnels.isEmpty()) {
Log.d(TAG, "No active tunnels, skipping reconnection")
return@launch
}
Log.i(TAG, "Reconnecting ${activeTunnels.size} tunnel(s) after network change: $oldType -> $newType")
for (tunnel in activeTunnels) {
try {
Log.d(TAG, "Disconnecting tunnel: ${tunnel.name}")
// Toggle tunnel off and on to reconnect
tunnel.setStateAsync(org.amnezia.awg.backend.Tunnel.State.DOWN)
kotlinx.coroutines.delay(500) // Small delay for cleanup
Log.d(TAG, "Reconnecting tunnel: ${tunnel.name}")
tunnel.setStateAsync(org.amnezia.awg.backend.Tunnel.State.UP)
Log.i(TAG, "Successfully reconnected tunnel: ${tunnel.name}")
} catch (e: Exception) {
Log.e(TAG, "Failed to reconnect tunnel ${tunnel.name}", e)
}
}
} catch (e: Exception) {
Log.e(TAG, "Error during network change handling", e)
}
}
}
companion object {
val USER_AGENT = String.format(Locale.ENGLISH, "AmneziaWG/%s (Android %d; %s; %s; %s %s; %s)", BuildConfig.VERSION_NAME, Build.VERSION.SDK_INT, if (Build.SUPPORTED_ABIS.isNotEmpty()) Build.SUPPORTED_ABIS[0] else "unknown ABI", Build.BOARD, Build.MANUFACTURER, Build.MODEL, Build.FINGERPRINT)
private const val TAG = "AmneziaWG/Application"
val USER_AGENT = String.format(Locale.ENGLISH, "WireGuard/%s (Android %d; %s; %s; %s %s; %s)", BuildConfig.VERSION_NAME, Build.VERSION.SDK_INT, if (Build.SUPPORTED_ABIS.isNotEmpty()) Build.SUPPORTED_ABIS[0] else "unknown ABI", Build.BOARD, Build.MANUFACTURER, Build.MODEL, Build.FINGERPRINT)
private const val TAG = "WireGuard/Application"
private lateinit var weakSelf: WeakReference<Application>
fun get(): Application {
@@ -204,8 +149,6 @@ class Application : android.app.Application() {
fun getTunnelManager() = get().tunnelManager
fun getCoroutineScope() = get().coroutineScope
fun getNetworkState() = get().networkState
}
init {
@@ -1,22 +1,22 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg
package com.wireguard.android
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.util.Log
import org.amnezia.awg.backend.AwgQuickBackend
import org.amnezia.awg.util.applicationScope
import com.wireguard.android.backend.WgQuickBackend
import com.wireguard.android.util.applicationScope
import kotlinx.coroutines.launch
class BootShutdownReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
val action = intent.action ?: return
applicationScope.launch {
if (Application.getBackend() !is AwgQuickBackend) return@launch
if (Application.getBackend() !is WgQuickBackend) return@launch
val tunnelManager = Application.getTunnelManager()
if (Intent.ACTION_BOOT_COMPLETED == action) {
Log.i(TAG, "Broadcast receiver restoring state (boot)")
@@ -29,6 +29,6 @@ class BootShutdownReceiver : BroadcastReceiver() {
}
companion object {
private const val TAG = "AmneziaWG/BootShutdownReceiver"
private const val TAG = "WireGuard/BootShutdownReceiver"
}
}
@@ -1,8 +1,8 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg
package com.wireguard.android
import android.app.PendingIntent
import android.content.Intent
@@ -19,12 +19,12 @@ import android.util.Log
import androidx.annotation.RequiresApi
import androidx.databinding.Observable
import androidx.databinding.Observable.OnPropertyChangedCallback
import org.amnezia.awg.activity.MainActivity
import org.amnezia.awg.activity.TunnelToggleActivity
import org.amnezia.awg.backend.Tunnel
import org.amnezia.awg.model.ObservableTunnel
import org.amnezia.awg.util.applicationScope
import org.amnezia.awg.widget.SlashDrawable
import com.wireguard.android.activity.MainActivity
import com.wireguard.android.activity.TunnelToggleActivity
import com.wireguard.android.backend.Tunnel
import com.wireguard.android.model.ObservableTunnel
import com.wireguard.android.util.applicationScope
import com.wireguard.android.widget.SlashDrawable
import kotlinx.coroutines.launch
/**
@@ -59,7 +59,7 @@ class QuickTileService : TileService() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
startActivityAndCollapse(PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_IMMUTABLE))
} else {
@Suppress("DEPRECATION", "StartActivityAndCollapseDeprecated")
@Suppress("DEPRECATION")
startActivityAndCollapse(intent)
}
}
@@ -180,7 +180,7 @@ class QuickTileService : TileService() {
}
companion object {
private const val TAG = "AmneziaWG/QuickTileService"
private const val TAG = "WireGuard/QuickTileService"
var isAdded: Boolean = false
private set
}
@@ -1,16 +1,16 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.activity
package com.wireguard.android.activity
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.CallbackRegistry
import androidx.databinding.CallbackRegistry.NotifierCallback
import androidx.lifecycle.lifecycleScope
import org.amnezia.awg.Application
import org.amnezia.awg.model.ObservableTunnel
import com.wireguard.android.Application
import com.wireguard.android.model.ObservableTunnel
import kotlinx.coroutines.launch
/**
@@ -1,9 +1,9 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.activity
package com.wireguard.android.activity
import android.content.ClipDescription.compareMimeTypes
import android.content.ContentProvider
@@ -36,13 +36,13 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.snackbar.Snackbar
import com.google.android.material.textview.MaterialTextView
import org.amnezia.awg.BuildConfig
import org.amnezia.awg.R
import org.amnezia.awg.databinding.LogViewerActivityBinding
import org.amnezia.awg.util.DownloadsFileSaver
import org.amnezia.awg.util.ErrorMessages
import org.amnezia.awg.util.resolveAttribute
import org.amnezia.awg.crypto.KeyPair
import com.wireguard.android.BuildConfig
import com.wireguard.android.R
import com.wireguard.android.databinding.LogViewerActivityBinding
import com.wireguard.android.util.DownloadsFileSaver
import com.wireguard.android.util.ErrorMessages
import com.wireguard.android.util.resolveAttribute
import com.wireguard.crypto.KeyPair
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
@@ -171,7 +171,7 @@ class LogViewerActivity : AppCompatActivity() {
var outputFile: DownloadsFileSaver.DownloadsFile? = null
withContext(Dispatchers.IO) {
try {
outputFile = downloadsFileSaver.save("amneziawg-log.txt", "text/plain", true)
outputFile = downloadsFileSaver.save("wireguard-log.txt", "text/plain", true)
outputFile?.outputStream?.write(rawLogBytes())
} catch (e: Throwable) {
outputFile?.delete()
@@ -294,7 +294,7 @@ class LogViewerActivity : AppCompatActivity() {
private val THREADTIME_LINE: Pattern =
Pattern.compile("^(\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}.\\d{3})(?:\\s+[0-9A-Za-z]+)?\\s+(\\d+)\\s+(\\d+)\\s+([A-Z])\\s+(.+?)\\s*: (.*)$")
private val LOGS: MutableMap<String, ByteArray> = ConcurrentHashMap()
private const val TAG = "AmneziaWG/LogViewerActivity"
private const val TAG = "WireGuard/LogViewerActivity"
}
private inner class LogEntryAdapter : RecyclerView.Adapter<LogEntryAdapter.ViewHolder>() {
@@ -353,7 +353,7 @@ class LogViewerActivity : AppCompatActivity() {
override fun query(uri: Uri, projection: Array<out String>?, selection: String?, selectionArgs: Array<out String>?, sortOrder: String?): Cursor? =
logForUri(uri)?.let {
val m = MatrixCursor(arrayOf(android.provider.OpenableColumns.DISPLAY_NAME, android.provider.OpenableColumns.SIZE), 1)
m.addRow(arrayOf("amneziawg-log.txt", it.size.toLong()))
m.addRow(arrayOf<Any>("wireguard-log.txt", it.size.toLong()))
m
}
@@ -1,8 +1,8 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.activity
package com.wireguard.android.activity
import android.content.Intent
import android.os.Bundle
@@ -15,15 +15,15 @@ import androidx.appcompat.app.ActionBar
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentTransaction
import androidx.fragment.app.commit
import org.amnezia.awg.R
import org.amnezia.awg.fragment.TunnelDetailFragment
import org.amnezia.awg.fragment.TunnelEditorFragment
import org.amnezia.awg.model.ObservableTunnel
import com.wireguard.android.R
import com.wireguard.android.fragment.TunnelDetailFragment
import com.wireguard.android.fragment.TunnelEditorFragment
import com.wireguard.android.model.ObservableTunnel
/**
* CRUD interface for AmneziaWG tunnels. This activity serves as the main entry point to the
* AmneziaWG application, and contains several fragments for listing, viewing details of, and
* editing the configuration and interface state of AmneziaWG tunnels.
* CRUD interface for WireGuard tunnels. This activity serves as the main entry point to the
* WireGuard application, and contains several fragments for listing, viewing details of, and
* editing the configuration and interface state of WireGuard tunnels.
*/
class MainActivity : BaseActivity(), FragmentManager.OnBackStackChangedListener {
private var actionBar: ActionBar? = null
@@ -80,7 +80,7 @@ class MainActivity : BaseActivity(), FragmentManager.OnBackStackChangedListener
R.id.menu_action_edit -> {
supportFragmentManager.commit {
replace(R.id.detail_container, TunnelEditorFragment())
replace(if (isTwoPaneLayout) R.id.detail_container else R.id.list_detail_container, TunnelEditorFragment())
setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
addToBackStack(null)
}
@@ -119,7 +119,7 @@ class MainActivity : BaseActivity(), FragmentManager.OnBackStackChangedListener
} else if (backStackEntries == 0) {
// Create and show a new detail fragment.
fragmentManager.commit {
add(R.id.detail_container, TunnelDetailFragment())
add(if (isTwoPaneLayout) R.id.detail_container else R.id.list_detail_container, TunnelDetailFragment())
setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
addToBackStack(null)
}
@@ -1,24 +1,27 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.activity
package com.wireguard.android.activity
import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.view.LayoutInflater
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.commit
import androidx.lifecycle.lifecycleScope
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import org.amnezia.awg.Application
import org.amnezia.awg.QuickTileService
import org.amnezia.awg.R
import org.amnezia.awg.backend.AwgQuickBackend
import org.amnezia.awg.preference.PreferencesPreferenceDataStore
import org.amnezia.awg.util.AdminKnobs
import com.wireguard.android.Application
import com.wireguard.android.QuickTileService
import com.wireguard.android.R
import com.wireguard.android.backend.WgQuickBackend
import com.wireguard.android.preference.PreferencesPreferenceDataStore
import com.wireguard.android.util.AdminKnobs
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
@@ -45,6 +48,15 @@ class SettingsActivity : AppCompatActivity() {
}
class SettingsFragment : PreferenceFragmentCompat() {
// Since this is pretty much abandoned by androidx, it never got updated for proper EdgeToEdge support,
// which is enabled everywhere for API 35. So handle the insets manually here.
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
val view = super.onCreateView(inflater, container, savedInstanceState)
view.fitsSystemWindows = true
return view
}
override fun onCreatePreferences(savedInstanceState: Bundle?, key: String?) {
preferenceManager.preferenceDataStore = PreferencesPreferenceDataStore(lifecycleScope, Application.getPreferencesDataStore())
addPreferencesFromResource(R.xml.preferences)
@@ -60,22 +72,26 @@ class SettingsActivity : AppCompatActivity() {
darkTheme?.parent?.removePreference(darkTheme)
--preferenceScreen.initialExpandedChildrenCount
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
val remoteApps = preferenceManager.findPreference<Preference>("allow_remote_control_intents")
remoteApps?.parent?.removePreference(remoteApps)
}
if (AdminKnobs.disableConfigExport) {
val zipExporter = preferenceManager.findPreference<Preference>("zip_exporter")
zipExporter?.parent?.removePreference(zipExporter)
}
val awgQuickOnlyPrefs = arrayOf(
val wgQuickOnlyPrefs = arrayOf(
preferenceManager.findPreference("tools_installer"),
preferenceManager.findPreference("restore_on_boot"),
preferenceManager.findPreference<Preference>("multiple_tunnels")
).filterNotNull()
awgQuickOnlyPrefs.forEach { it.isVisible = false }
wgQuickOnlyPrefs.forEach { it.isVisible = false }
lifecycleScope.launch {
if (Application.getBackend() is AwgQuickBackend) {
if (Application.getBackend() is WgQuickBackend) {
++preferenceScreen.initialExpandedChildrenCount
awgQuickOnlyPrefs.forEach { it.isVisible = true }
wgQuickOnlyPrefs.forEach { it.isVisible = true }
} else {
awgQuickOnlyPrefs.forEach { it.parent?.removePreference(it) }
wgQuickOnlyPrefs.forEach { it.parent?.removePreference(it) }
}
}
preferenceManager.findPreference<Preference>("log_viewer")?.setOnPreferenceClickListener {
@@ -83,9 +99,9 @@ class SettingsActivity : AppCompatActivity() {
true
}
val kernelModuleEnabler = preferenceManager.findPreference<Preference>("kernel_module_enabler")
if (AwgQuickBackend.hasKernelSupport()) {
if (WgQuickBackend.hasKernelSupport()) {
lifecycleScope.launch {
if (Application.getBackend() !is AwgQuickBackend) {
if (Application.getBackend() !is WgQuickBackend) {
try {
withContext(Dispatchers.IO) { Application.getRootShell().start() }
} catch (_: Throwable) {
@@ -0,0 +1,24 @@
/*
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package com.wireguard.android.activity
import android.os.Bundle
import com.wireguard.android.R
import com.wireguard.android.model.ObservableTunnel
/**
* Standalone activity for creating tunnels.
*/
class TunnelCreatorActivity : BaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.tunnel_creator_activity)
}
override fun onSelectedTunnelChanged(oldTunnel: ObservableTunnel?, newTunnel: ObservableTunnel?): Boolean {
finish()
return true
}
}
@@ -1,25 +1,28 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.activity
package com.wireguard.android.activity
import android.content.ComponentName
import android.os.Build
import android.os.Bundle
import android.service.quicksettings.TileService
import android.util.Log
import android.widget.Toast
import androidx.activity.result.contract.ActivityResultContracts
import androidx.annotation.RequiresApi
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope
import org.amnezia.awg.Application
import org.amnezia.awg.QuickTileService
import org.amnezia.awg.R
import org.amnezia.awg.backend.GoBackend
import org.amnezia.awg.backend.Tunnel
import org.amnezia.awg.util.ErrorMessages
import com.wireguard.android.Application
import com.wireguard.android.QuickTileService
import com.wireguard.android.R
import com.wireguard.android.backend.GoBackend
import com.wireguard.android.backend.Tunnel
import com.wireguard.android.util.ErrorMessages
import kotlinx.coroutines.launch
@RequiresApi(Build.VERSION_CODES.N)
class TunnelToggleActivity : AppCompatActivity() {
private val permissionActivityResultLauncher =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { toggleTunnelWithPermissionsResult() }
@@ -47,10 +50,14 @@ class TunnelToggleActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
lifecycleScope.launch {
if (Application.getBackend() is GoBackend) {
val intent = GoBackend.VpnService.prepare(this@TunnelToggleActivity)
if (intent != null) {
permissionActivityResultLauncher.launch(intent)
return@launch
try {
val intent = GoBackend.VpnService.prepare(this@TunnelToggleActivity)
if (intent != null) {
permissionActivityResultLauncher.launch(intent)
return@launch
}
} catch (e: Exception) {
Toast.makeText(this@TunnelToggleActivity, ErrorMessages[e], Toast.LENGTH_LONG).show()
}
}
toggleTunnelWithPermissionsResult()
@@ -58,6 +65,6 @@ class TunnelToggleActivity : AppCompatActivity() {
}
companion object {
private const val TAG = "AmneziaWG/TunnelToggleActivity"
private const val TAG = "WireGuard/TunnelToggleActivity"
}
}
@@ -1,9 +1,9 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.activity
package com.wireguard.android.activity
import android.Manifest
import android.content.ActivityNotFoundException
@@ -34,22 +34,22 @@ import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.GridLayoutManager.SpanSizeLookup
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import org.amnezia.awg.Application
import org.amnezia.awg.R
import org.amnezia.awg.backend.GoBackend
import org.amnezia.awg.backend.Tunnel
import org.amnezia.awg.databinding.Keyed
import org.amnezia.awg.databinding.ObservableKeyedArrayList
import org.amnezia.awg.databinding.ObservableKeyedRecyclerViewAdapter
import org.amnezia.awg.databinding.TvActivityBinding
import org.amnezia.awg.databinding.TvFileListItemBinding
import org.amnezia.awg.databinding.TvTunnelListItemBinding
import org.amnezia.awg.model.ObservableTunnel
import org.amnezia.awg.util.ErrorMessages
import org.amnezia.awg.util.QuantityFormatter
import org.amnezia.awg.util.TunnelImporter
import org.amnezia.awg.util.UserKnobs
import org.amnezia.awg.util.applicationScope
import com.wireguard.android.Application
import com.wireguard.android.R
import com.wireguard.android.backend.GoBackend
import com.wireguard.android.backend.Tunnel
import com.wireguard.android.databinding.Keyed
import com.wireguard.android.databinding.ObservableKeyedArrayList
import com.wireguard.android.databinding.ObservableKeyedRecyclerViewAdapter
import com.wireguard.android.databinding.TvActivityBinding
import com.wireguard.android.databinding.TvFileListItemBinding
import com.wireguard.android.databinding.TvTunnelListItemBinding
import com.wireguard.android.model.ObservableTunnel
import com.wireguard.android.util.ErrorMessages
import com.wireguard.android.util.QuantityFormatter
import com.wireguard.android.util.TunnelImporter
import com.wireguard.android.util.UserKnobs
import com.wireguard.android.util.applicationScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
@@ -214,10 +214,7 @@ class TvMainActivity : AppCompatActivity() {
MaterialAlertDialogBuilder(binding.root.context).setMessage(R.string.tv_no_file_picker).setCancelable(false)
.setPositiveButton(android.R.string.ok) { _, _ ->
try {
startActivity(Intent(Intent.ACTION_VIEW).apply {
data = Uri.parse("https://play.google.com/store/apps/details?id=com.cxinventor.file.explorer")
setPackage("com.android.vending")
})
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("market://webstoreredirect")))
} catch (_: Throwable) {
}
}.show()
@@ -266,14 +263,31 @@ class TvMainActivity : AppCompatActivity() {
private suspend fun makeStorageRoots(): Collection<KeyedFile> = withContext(Dispatchers.IO) {
cachedRoots?.let { return@withContext it }
val list = HashSet<KeyedFile>()
val storageManager: StorageManager = getSystemService() ?: return@withContext list
list.addAll(storageManager.storageVolumes.mapNotNull { volume ->
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
volume.directory?.let { KeyedFile(it, volume.getDescription(this@TvMainActivity)) }
} else {
KeyedFile((StorageVolume::class.java.getMethod("getPathFile").invoke(volume) as File), volume.getDescription(this@TvMainActivity))
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
val storageManager: StorageManager = getSystemService() ?: return@withContext list
list.addAll(storageManager.storageVolumes.mapNotNull { volume ->
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
volume.directory?.let { KeyedFile(it, volume.getDescription(this@TvMainActivity)) }
} else {
KeyedFile((StorageVolume::class.java.getMethod("getPathFile").invoke(volume) as File), volume.getDescription(this@TvMainActivity))
}
})
} else {
@Suppress("DEPRECATION")
list.add(KeyedFile(Environment.getExternalStorageDirectory()))
try {
File("/storage").listFiles()?.forEach {
if (!it.isDirectory) return@forEach
try {
if (Environment.isExternalStorageRemovable(it)) {
list.add(KeyedFile(it))
}
} catch (_: Throwable) {
}
}
} catch (_: Throwable) {
}
})
}
cachedRoots = list
list
}
@@ -426,6 +440,6 @@ class TvMainActivity : AppCompatActivity() {
}
companion object {
private const val TAG = "AmneziaWG/TvMainActivity"
private const val TAG = "WireGuard/TvMainActivity"
}
}
@@ -1,13 +1,13 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.configStore
package com.wireguard.android.configStore
import org.amnezia.awg.config.Config
import com.wireguard.config.Config
/**
* Interface for persistent storage providers for AmneziaWG configurations.
* Interface for persistent storage providers for WireGuard configurations.
*/
interface ConfigStore {
/**
@@ -1,14 +1,14 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.configStore
package com.wireguard.android.configStore
import android.content.Context
import android.util.Log
import org.amnezia.awg.R
import org.amnezia.awg.config.BadConfigException
import org.amnezia.awg.config.Config
import com.wireguard.android.R
import com.wireguard.config.BadConfigException
import com.wireguard.config.Config
import java.io.File
import java.io.FileInputStream
import java.io.FileNotFoundException
@@ -17,7 +17,7 @@ import java.io.IOException
import java.nio.charset.StandardCharsets
/**
* Configuration store that uses a `awg-quick`-style file for each configured tunnel.
* Configuration store that uses a `wg-quick`-style file for each configured tunnel.
*/
class FileConfigStore(private val context: Context) : ConfigStore {
@Throws(IOException::class)
@@ -26,7 +26,7 @@ class FileConfigStore(private val context: Context) : ConfigStore {
val file = fileFor(name)
if (!file.createNewFile())
throw IOException(context.getString(R.string.config_file_exists_error, file.name))
FileOutputStream(file, false).use { it.write(config.toAwgQuickString().toByteArray(StandardCharsets.UTF_8)) }
FileOutputStream(file, false).use { it.write(config.toWgQuickString().toByteArray(StandardCharsets.UTF_8)) }
return config
}
@@ -72,11 +72,11 @@ class FileConfigStore(private val context: Context) : ConfigStore {
val file = fileFor(name)
if (!file.isFile)
throw FileNotFoundException(context.getString(R.string.config_not_found_error, file.name))
FileOutputStream(file, false).use { stream -> stream.write(config.toAwgQuickString().toByteArray(StandardCharsets.UTF_8)) }
FileOutputStream(file, false).use { stream -> stream.write(config.toWgQuickString().toByteArray(StandardCharsets.UTF_8)) }
return config
}
companion object {
private const val TAG = "AmneziaWG/FileConfigStore"
private const val TAG = "WireGuard/FileConfigStore"
}
}
@@ -1,8 +1,8 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.databinding
package com.wireguard.android.databinding
import android.text.InputFilter
import android.view.LayoutInflater
@@ -18,14 +18,14 @@ import androidx.databinding.adapters.ListenerUtil
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import org.amnezia.awg.BR
import org.amnezia.awg.R
import org.amnezia.awg.databinding.ObservableKeyedRecyclerViewAdapter.RowConfigurationHandler
import org.amnezia.awg.widget.ToggleSwitch
import org.amnezia.awg.widget.ToggleSwitch.OnBeforeCheckedChangeListener
import org.amnezia.awg.widget.TvCardView
import org.amnezia.awg.config.Attribute
import org.amnezia.awg.config.InetNetwork
import com.wireguard.android.BR
import com.wireguard.android.R
import com.wireguard.android.databinding.ObservableKeyedRecyclerViewAdapter.RowConfigurationHandler
import com.wireguard.android.widget.ToggleSwitch
import com.wireguard.android.widget.ToggleSwitch.OnBeforeCheckedChangeListener
import com.wireguard.android.widget.TvCardView
import com.wireguard.config.Attribute
import com.wireguard.config.InetNetwork
import java.net.InetAddress
import java.util.Optional
@@ -1,8 +1,8 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.databinding
package com.wireguard.android.databinding
import android.view.LayoutInflater
import android.view.View
@@ -11,7 +11,7 @@ import androidx.databinding.DataBindingUtil
import androidx.databinding.ObservableList
import androidx.databinding.ViewDataBinding
import androidx.fragment.app.Fragment
import org.amnezia.awg.BR
import com.wireguard.android.BR
import java.lang.ref.WeakReference
/**
@@ -1,8 +1,8 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.databinding
package com.wireguard.android.databinding
/**
* Interface for objects that have a identifying key of the given type.
@@ -1,8 +1,8 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.databinding
package com.wireguard.android.databinding
import androidx.databinding.ObservableArrayList
@@ -1,8 +1,8 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.databinding
package com.wireguard.android.databinding
import android.content.Context
import android.view.LayoutInflater
@@ -11,7 +11,7 @@ import androidx.databinding.DataBindingUtil
import androidx.databinding.ObservableList
import androidx.databinding.ViewDataBinding
import androidx.recyclerview.widget.RecyclerView
import org.amnezia.awg.BR
import com.wireguard.android.BR
import java.lang.ref.WeakReference
/**
@@ -1,8 +1,8 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.databinding
package com.wireguard.android.databinding
import java.util.AbstractList
import java.util.Collections
@@ -1,26 +1,24 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.fragment
package com.wireguard.android.fragment
import android.content.pm.PackageManager
import android.graphics.drawable.GradientDrawable
import android.os.Bundle
import android.text.method.LinkMovementMethod
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.ViewTreeObserver
import android.widget.FrameLayout
import android.widget.TextView
import androidx.core.os.bundleOf
import androidx.fragment.app.setFragmentResult
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import org.amnezia.awg.R
import org.amnezia.awg.util.resolveAttribute
import com.wireguard.android.R
import com.wireguard.android.util.resolveAttribute
class AddTunnelsSheet : BottomSheetDialogFragment() {
@@ -44,7 +42,6 @@ class AddTunnelsSheet : BottomSheetDialogFragment() {
qrcode.isEnabled = false
qrcode.visibility = View.GONE
}
view.findViewById<TextView>(R.id.disclaimer)?.let { it.movementMethod = LinkMovementMethod.getInstance() }
return view
}
@@ -1,8 +1,8 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.fragment
package com.wireguard.android.fragment
import android.Manifest
import android.app.Dialog
@@ -21,12 +21,12 @@ import androidx.fragment.app.setFragmentResult
import androidx.lifecycle.lifecycleScope
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.tabs.TabLayout
import org.amnezia.awg.BR
import org.amnezia.awg.R
import org.amnezia.awg.databinding.AppListDialogFragmentBinding
import org.amnezia.awg.databinding.ObservableKeyedArrayList
import org.amnezia.awg.model.ApplicationData
import org.amnezia.awg.util.ErrorMessages
import com.wireguard.android.BR
import com.wireguard.android.R
import com.wireguard.android.databinding.AppListDialogFragmentBinding
import com.wireguard.android.databinding.ObservableKeyedArrayList
import com.wireguard.android.model.ApplicationData
import com.wireguard.android.util.ErrorMessages
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
@@ -48,9 +48,9 @@ class AppListDialogFragment : DialogFragment() {
val packageInfos = getPackagesHoldingPermissions(pm, arrayOf(Manifest.permission.INTERNET))
packageInfos.forEach {
val packageName = it.packageName
val appInfo = it.applicationInfo
val appInfo = it.applicationInfo ?: return@forEach
val appData =
ApplicationData(appInfo?.loadIcon(pm) ?: pm.defaultActivityIcon, appInfo?.loadLabel(pm)?.toString() ?: packageName, packageName, currentlySelectedApps.contains(packageName))
ApplicationData(appInfo.loadIcon(pm), appInfo.loadLabel(pm).toString(), packageName, currentlySelectedApps.contains(packageName))
applicationData.add(appData)
appData.addOnPropertyChangedCallback(object : Observable.OnPropertyChangedCallback() {
override fun onPropertyChanged(sender: Observable?, propertyId: Int) {
@@ -1,8 +1,8 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.fragment
package com.wireguard.android.fragment
import android.content.Context
import android.util.Log
@@ -14,16 +14,16 @@ import androidx.databinding.ViewDataBinding
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import com.google.android.material.snackbar.Snackbar
import org.amnezia.awg.Application
import org.amnezia.awg.R
import org.amnezia.awg.activity.BaseActivity
import org.amnezia.awg.activity.BaseActivity.OnSelectedTunnelChangedListener
import org.amnezia.awg.backend.GoBackend
import org.amnezia.awg.backend.Tunnel
import org.amnezia.awg.databinding.TunnelDetailFragmentBinding
import org.amnezia.awg.databinding.TunnelListItemBinding
import org.amnezia.awg.model.ObservableTunnel
import org.amnezia.awg.util.ErrorMessages
import com.wireguard.android.Application
import com.wireguard.android.R
import com.wireguard.android.activity.BaseActivity
import com.wireguard.android.activity.BaseActivity.OnSelectedTunnelChangedListener
import com.wireguard.android.backend.GoBackend
import com.wireguard.android.backend.Tunnel
import com.wireguard.android.databinding.TunnelDetailFragmentBinding
import com.wireguard.android.databinding.TunnelListItemBinding
import com.wireguard.android.model.ObservableTunnel
import com.wireguard.android.util.ErrorMessages
import kotlinx.coroutines.launch
/**
@@ -109,6 +109,6 @@ abstract class BaseFragment : Fragment(), OnSelectedTunnelChangedListener {
}
companion object {
private const val TAG = "AmneziaWG/BaseFragment"
private const val TAG = "WireGuard/BaseFragment"
}
}
@@ -1,8 +1,8 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.fragment
package com.wireguard.android.fragment
import android.app.Dialog
import android.os.Bundle
@@ -10,11 +10,11 @@ import android.view.WindowManager
import androidx.fragment.app.DialogFragment
import androidx.lifecycle.lifecycleScope
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import org.amnezia.awg.Application
import org.amnezia.awg.R
import org.amnezia.awg.databinding.ConfigNamingDialogFragmentBinding
import org.amnezia.awg.config.BadConfigException
import org.amnezia.awg.config.Config
import com.wireguard.android.Application
import com.wireguard.android.R
import com.wireguard.android.databinding.ConfigNamingDialogFragmentBinding
import com.wireguard.config.BadConfigException
import com.wireguard.config.Config
import kotlinx.coroutines.launch
import java.io.ByteArrayInputStream
import java.io.IOException
@@ -1,8 +1,8 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.fragment
package com.wireguard.android.fragment
import android.os.Bundle
import android.view.LayoutInflater
@@ -15,12 +15,12 @@ import androidx.core.view.MenuProvider
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import org.amnezia.awg.R
import org.amnezia.awg.backend.Tunnel
import org.amnezia.awg.databinding.TunnelDetailFragmentBinding
import org.amnezia.awg.databinding.TunnelDetailPeerBinding
import org.amnezia.awg.model.ObservableTunnel
import org.amnezia.awg.util.QuantityFormatter
import com.wireguard.android.R
import com.wireguard.android.backend.Tunnel
import com.wireguard.android.databinding.TunnelDetailFragmentBinding
import com.wireguard.android.databinding.TunnelDetailPeerBinding
import com.wireguard.android.model.ObservableTunnel
import com.wireguard.android.util.QuantityFormatter
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
@@ -1,8 +1,8 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.fragment
package com.wireguard.android.fragment
import android.content.Context
import android.os.Bundle
@@ -23,20 +23,20 @@ import androidx.core.view.MenuProvider
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import com.google.android.material.snackbar.Snackbar
import org.amnezia.awg.Application
import org.amnezia.awg.R
import org.amnezia.awg.backend.Tunnel
import org.amnezia.awg.databinding.TunnelEditorFragmentBinding
import org.amnezia.awg.model.ObservableTunnel
import org.amnezia.awg.util.AdminKnobs
import org.amnezia.awg.util.BiometricAuthenticator
import org.amnezia.awg.util.ErrorMessages
import org.amnezia.awg.viewmodel.ConfigProxy
import org.amnezia.awg.config.Config
import com.wireguard.android.Application
import com.wireguard.android.R
import com.wireguard.android.backend.Tunnel
import com.wireguard.android.databinding.TunnelEditorFragmentBinding
import com.wireguard.android.model.ObservableTunnel
import com.wireguard.android.util.AdminKnobs
import com.wireguard.android.util.BiometricAuthenticator
import com.wireguard.android.util.ErrorMessages
import com.wireguard.android.viewmodel.ConfigProxy
import com.wireguard.config.Config
import kotlinx.coroutines.launch
/**
* Fragment for editing an AmneziaWG configuration.
* Fragment for editing a WireGuard configuration.
*/
class TunnelEditorFragment : BaseFragment(), MenuProvider {
private var haveShownKeys = false
@@ -328,6 +328,6 @@ class TunnelEditorFragment : BaseFragment(), MenuProvider {
companion object {
private const val KEY_LOCAL_CONFIG = "local_config"
private const val KEY_ORIGINAL_NAME = "original_name"
private const val TAG = "AmneziaWG/TunnelEditorFragment"
private const val TAG = "WireGuard/TunnelEditorFragment"
}
}
@@ -1,8 +1,8 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.fragment
package com.wireguard.android.fragment
import android.content.Intent
import android.content.res.Resources
@@ -26,24 +26,25 @@ import com.google.android.material.snackbar.Snackbar
import com.google.zxing.qrcode.QRCodeReader
import com.journeyapps.barcodescanner.ScanContract
import com.journeyapps.barcodescanner.ScanOptions
import org.amnezia.awg.Application
import org.amnezia.awg.R
import org.amnezia.awg.activity.TunnelCreatorActivity
import org.amnezia.awg.databinding.ObservableKeyedRecyclerViewAdapter.RowConfigurationHandler
import org.amnezia.awg.databinding.TunnelListFragmentBinding
import org.amnezia.awg.databinding.TunnelListItemBinding
import org.amnezia.awg.model.ObservableTunnel
import org.amnezia.awg.util.ErrorMessages
import org.amnezia.awg.util.QrCodeFromFileScanner
import org.amnezia.awg.util.TunnelImporter
import org.amnezia.awg.widget.MultiselectableRelativeLayout
import com.wireguard.android.Application
import com.wireguard.android.R
import com.wireguard.android.activity.TunnelCreatorActivity
import com.wireguard.android.databinding.ObservableKeyedRecyclerViewAdapter.RowConfigurationHandler
import com.wireguard.android.databinding.TunnelListFragmentBinding
import com.wireguard.android.databinding.TunnelListItemBinding
import com.wireguard.android.model.ObservableTunnel
import com.wireguard.android.updater.SnackbarUpdateShower
import com.wireguard.android.util.ErrorMessages
import com.wireguard.android.util.QrCodeFromFileScanner
import com.wireguard.android.util.TunnelImporter
import com.wireguard.android.widget.MultiselectableRelativeLayout
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.launch
/**
* Fragment containing a list of known AmneziaWG tunnels. It allows creating and deleting tunnels.
* Fragment containing a list of known WireGuard tunnels. It allows creating and deleting tunnels.
*/
class TunnelListFragment : BaseFragment() {
private val actionModeListener = ActionModeListener()
@@ -80,6 +81,8 @@ class TunnelListFragment : BaseFragment() {
}
}
private val snackbarUpdateShower = SnackbarUpdateShower(this)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
if (savedInstanceState != null) {
@@ -124,6 +127,7 @@ class TunnelListFragment : BaseFragment() {
bottomSheet.showNow(childFragmentManager, "BOTTOM_SHEET")
}
executePendingBindings()
snackbarUpdateShower.attach(mainContainer, createFab)
}
backPressedCallback = requireActivity().onBackPressedDispatcher.addCallback(this) { actionMode?.finish() }
backPressedCallback?.isEnabled = false
@@ -333,6 +337,6 @@ class TunnelListFragment : BaseFragment() {
companion object {
private const val CHECKED_ITEMS = "CHECKED_ITEMS"
private const val TAG = "AmneziaWG/TunnelListFragment"
private const val TAG = "WireGuard/TunnelListFragment"
}
}
@@ -1,14 +1,14 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.model
package com.wireguard.android.model
import android.graphics.drawable.Drawable
import androidx.databinding.BaseObservable
import androidx.databinding.Bindable
import org.amnezia.awg.BR
import org.amnezia.awg.databinding.Keyed
import com.wireguard.android.BR
import com.wireguard.android.databinding.Keyed
class ApplicationData(val icon: Drawable, val name: String, val packageName: String, isSelected: Boolean) : BaseObservable(), Keyed<String> {
override val key = name
@@ -1,24 +1,24 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.model
package com.wireguard.android.model
import android.util.Log
import androidx.databinding.BaseObservable
import androidx.databinding.Bindable
import org.amnezia.awg.BR
import org.amnezia.awg.backend.Statistics
import org.amnezia.awg.backend.Tunnel
import org.amnezia.awg.databinding.Keyed
import org.amnezia.awg.util.applicationScope
import org.amnezia.awg.config.Config
import com.wireguard.android.BR
import com.wireguard.android.backend.Statistics
import com.wireguard.android.backend.Tunnel
import com.wireguard.android.databinding.Keyed
import com.wireguard.android.util.applicationScope
import com.wireguard.config.Config
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
/**
* Encapsulates the volatile and nonvolatile state of an AmneziaWG tunnel.
* Encapsulates the volatile and nonvolatile state of a WireGuard tunnel.
*/
class ObservableTunnel internal constructor(
private val manager: TunnelManager,
@@ -50,42 +50,17 @@ class ObservableTunnel internal constructor(
var state = state
private set
@get:Bindable
var connectionStatus: ConnectionStatus = ConnectionStatus.DISCONNECTED
private set
override fun onStateChange(newState: Tunnel.State) {
onStateChanged(newState)
}
fun onStateChanged(state: Tunnel.State): Tunnel.State {
if (state != Tunnel.State.UP) {
onStatisticsChanged(null)
onConnectionStatusChanged(ConnectionStatus.DISCONNECTED)
} else if (connectionStatus == ConnectionStatus.DISCONNECTED) {
// When state changes to UP, set to CONNECTING until handshake confirms
onConnectionStatusChanged(ConnectionStatus.CONNECTING)
}
if (state != Tunnel.State.UP) onStatisticsChanged(null)
this.state = state
notifyPropertyChanged(BR.state)
return state
}
fun onConnectionStatusChanged(status: ConnectionStatus): ConnectionStatus {
if (status != this.connectionStatus) {
this.connectionStatus = status
notifyPropertyChanged(BR.connectionStatus)
Log.d(TAG, "Connection status changed for $name: $status")
}
return status
}
enum class ConnectionStatus {
DISCONNECTED,
CONNECTING,
CONNECTED
}
suspend fun setStateAsync(state: Tunnel.State): Tunnel.State = withContext(Dispatchers.Main.immediate) {
if (state != this@ObservableTunnel.state)
manager.setTunnelState(this@ObservableTunnel, state)
@@ -166,6 +141,6 @@ class ObservableTunnel internal constructor(
companion object {
private const val TAG = "AmneziaWG/ObservableTunnel"
private const val TAG = "WireGuard/ObservableTunnel"
}
}
@@ -1,9 +1,9 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.model
package com.wireguard.android.model
object TunnelComparator : Comparator<String> {
private class NaturalSortString(originalString: String) {
@@ -1,8 +1,8 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.model
package com.wireguard.android.model
import android.content.BroadcastReceiver
import android.content.Context
@@ -12,20 +12,19 @@ import android.util.Log
import android.widget.Toast
import androidx.databinding.BaseObservable
import androidx.databinding.Bindable
import org.amnezia.awg.Application.Companion.get
import org.amnezia.awg.Application.Companion.getBackend
import org.amnezia.awg.Application.Companion.getTunnelManager
import org.amnezia.awg.BR
import org.amnezia.awg.R
import org.amnezia.awg.backend.Statistics
import org.amnezia.awg.backend.StatusCallback
import org.amnezia.awg.backend.Tunnel
import org.amnezia.awg.configStore.ConfigStore
import org.amnezia.awg.databinding.ObservableSortedKeyedArrayList
import org.amnezia.awg.util.ErrorMessages
import org.amnezia.awg.util.UserKnobs
import org.amnezia.awg.util.applicationScope
import org.amnezia.awg.config.Config
import com.wireguard.android.Application.Companion.get
import com.wireguard.android.Application.Companion.getBackend
import com.wireguard.android.Application.Companion.getTunnelManager
import com.wireguard.android.BR
import com.wireguard.android.R
import com.wireguard.android.backend.Statistics
import com.wireguard.android.backend.Tunnel
import com.wireguard.android.configStore.ConfigStore
import com.wireguard.android.databinding.ObservableSortedKeyedArrayList
import com.wireguard.android.util.ErrorMessages
import com.wireguard.android.util.UserKnobs
import com.wireguard.android.util.applicationScope
import com.wireguard.config.Config
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
@@ -36,7 +35,7 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
/**
* Maintains and mediates changes to the set of available AmneziaWG tunnels,
* Maintains and mediates changes to the set of available WireGuard tunnels,
*/
class TunnelManager(private val configStore: ConfigStore) : BaseObservable() {
private val tunnels = CompletableDeferred<ObservableSortedKeyedArrayList<String, ObservableTunnel>>()
@@ -103,41 +102,12 @@ class TunnelManager(private val configStore: ConfigStore) : BaseObservable() {
applicationScope.launch {
try {
onTunnelsLoaded(withContext(Dispatchers.IO) { configStore.enumerate() }, withContext(Dispatchers.IO) { getBackend().runningTunnelNames })
setupStatusCallbacks()
} catch (e: Throwable) {
Log.e(TAG, Log.getStackTraceString(e))
}
}
}
private fun setupStatusCallbacks() {
applicationScope.launch {
try {
val backend = getBackend()
val statusCallback = object : StatusCallback {
override fun onStatusChanged(connected: Boolean) {
applicationScope.launch(Dispatchers.Main) {
// Find the currently active tunnel
val activeTunnel = tunnelMap.firstOrNull { it.state == Tunnel.State.UP }
if (activeTunnel != null) {
val newStatus = if (connected) {
ObservableTunnel.ConnectionStatus.CONNECTED
} else {
ObservableTunnel.ConnectionStatus.CONNECTING
}
activeTunnel.onConnectionStatusChanged(newStatus)
}
}
}
}
backend.setStatusCallback(statusCallback)
} catch (e: Throwable) {
Log.e(TAG, "Failed to setup status callbacks", e)
}
}
}
private fun onTunnelsLoaded(present: Iterable<String>, running: Collection<String>) {
for (name in present)
addToList(name, null, if (running.contains(name)) Tunnel.State.UP else Tunnel.State.DOWN)
@@ -247,7 +217,7 @@ class TunnelManager(private val configStore: ConfigStore) : BaseObservable() {
val manager = getTunnelManager()
if (intent == null) return@launch
val action = intent.action ?: return@launch
if ("org.amnezia.awg.action.REFRESH_TUNNEL_STATES" == action) {
if ("com.wireguard.android.action.REFRESH_TUNNEL_STATES" == action) {
manager.refreshTunnelStates()
return@launch
}
@@ -255,8 +225,8 @@ class TunnelManager(private val configStore: ConfigStore) : BaseObservable() {
return@launch
val state: Tunnel.State
state = when (action) {
"org.amnezia.awg.action.SET_TUNNEL_UP" -> Tunnel.State.UP
"org.amnezia.awg.action.SET_TUNNEL_DOWN" -> Tunnel.State.DOWN
"com.wireguard.android.action.SET_TUNNEL_UP" -> Tunnel.State.UP
"com.wireguard.android.action.SET_TUNNEL_DOWN" -> Tunnel.State.DOWN
else -> return@launch
}
val tunnelName = intent.getStringExtra("tunnel") ?: return@launch
@@ -280,6 +250,6 @@ class TunnelManager(private val configStore: ConfigStore) : BaseObservable() {
}
companion object {
private const val TAG = "AmneziaWG/TunnelManager"
private const val TAG = "WireGuard/TunnelManager"
}
}
@@ -0,0 +1,42 @@
/*
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package com.wireguard.android.preference
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.util.AttributeSet
import android.widget.Toast
import androidx.preference.Preference
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.wireguard.android.R
import com.wireguard.android.updater.Updater
import com.wireguard.android.util.ErrorMessages
class DonatePreference(context: Context, attrs: AttributeSet?) : Preference(context, attrs) {
override fun getSummary() = context.getString(R.string.donate_summary)
override fun getTitle() = context.getString(R.string.donate_title)
override fun onClick() {
/* Google Play Store forbids links to our donation page. */
if (Updater.installerIsGooglePlay(context)) {
MaterialAlertDialogBuilder(context)
.setTitle(R.string.donate_title)
.setMessage(R.string.donate_google_play_disappointment)
.show()
return
}
val intent = Intent(Intent.ACTION_VIEW)
intent.data = Uri.parse("https://www.wireguard.com/donations/")
try {
context.startActivity(intent)
} catch (e: Throwable) {
Toast.makeText(context, ErrorMessages[e], Toast.LENGTH_SHORT).show()
}
}
}
@@ -1,8 +1,8 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.preference
package com.wireguard.android.preference
import android.content.Context
import android.content.Intent
@@ -10,14 +10,14 @@ import android.util.AttributeSet
import android.util.Log
import androidx.lifecycle.lifecycleScope
import androidx.preference.Preference
import org.amnezia.awg.Application
import org.amnezia.awg.R
import org.amnezia.awg.activity.SettingsActivity
import org.amnezia.awg.backend.Tunnel
import org.amnezia.awg.backend.AwgQuickBackend
import org.amnezia.awg.util.UserKnobs
import org.amnezia.awg.util.activity
import org.amnezia.awg.util.lifecycleScope
import com.wireguard.android.Application
import com.wireguard.android.R
import com.wireguard.android.activity.SettingsActivity
import com.wireguard.android.backend.Tunnel
import com.wireguard.android.backend.WgQuickBackend
import com.wireguard.android.util.UserKnobs
import com.wireguard.android.util.activity
import com.wireguard.android.util.lifecycleScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.async
@@ -32,7 +32,7 @@ class KernelModuleEnablerPreference(context: Context, attrs: AttributeSet?) : Pr
init {
isVisible = false
lifecycleScope.launch {
setState(if (Application.getBackend() is AwgQuickBackend) State.ENABLED else State.DISABLED)
setState(if (Application.getBackend() is WgQuickBackend) State.ENABLED else State.DISABLED)
}
}
@@ -83,6 +83,6 @@ class KernelModuleEnablerPreference(context: Context, attrs: AttributeSet?) : Pr
}
companion object {
private const val TAG = "AmneziaWG/KernelModuleEnablerPreference"
private const val TAG = "WireGuard/KernelModuleEnablerPreference"
}
}
@@ -1,9 +1,9 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.preference
package com.wireguard.android.preference
import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.Preferences
@@ -1,9 +1,9 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.preference
package com.wireguard.android.preference
import android.app.StatusBarManager
import android.content.ComponentName
@@ -14,8 +14,8 @@ import android.util.AttributeSet
import android.widget.Toast
import androidx.annotation.RequiresApi
import androidx.preference.Preference
import org.amnezia.awg.QuickTileService
import org.amnezia.awg.R
import com.wireguard.android.QuickTileService
import com.wireguard.android.R
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
class QuickTilePreference(context: Context, attrs: AttributeSet?) : Preference(context, attrs) {
@@ -1,16 +1,16 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.preference
package com.wireguard.android.preference
import android.content.Context
import android.util.AttributeSet
import androidx.preference.Preference
import org.amnezia.awg.Application
import org.amnezia.awg.R
import org.amnezia.awg.util.ToolsInstaller
import org.amnezia.awg.util.lifecycleScope
import com.wireguard.android.Application
import com.wireguard.android.R
import com.wireguard.android.util.ToolsInstaller
import com.wireguard.android.util.lifecycleScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
@@ -1,8 +1,8 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.preference
package com.wireguard.android.preference
import android.content.Context
import android.content.Intent
@@ -10,14 +10,14 @@ import android.net.Uri
import android.util.AttributeSet
import android.widget.Toast
import androidx.preference.Preference
import org.amnezia.awg.Application
import org.amnezia.awg.BuildConfig
import org.amnezia.awg.R
import org.amnezia.awg.backend.Backend
import org.amnezia.awg.backend.GoBackend
import org.amnezia.awg.backend.AwgQuickBackend
import org.amnezia.awg.util.ErrorMessages
import org.amnezia.awg.util.lifecycleScope
import com.wireguard.android.Application
import com.wireguard.android.BuildConfig
import com.wireguard.android.R
import com.wireguard.android.backend.Backend
import com.wireguard.android.backend.GoBackend
import com.wireguard.android.backend.WgQuickBackend
import com.wireguard.android.util.ErrorMessages
import com.wireguard.android.util.lifecycleScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
@@ -31,7 +31,7 @@ class VersionPreference(context: Context, attrs: AttributeSet?) : Preference(con
override fun onClick() {
val intent = Intent(Intent.ACTION_VIEW)
intent.data = Uri.parse("https://amnezia.org/")
intent.data = Uri.parse("https://www.wireguard.com/")
try {
context.startActivity(intent)
} catch (e: Throwable) {
@@ -41,7 +41,7 @@ class VersionPreference(context: Context, attrs: AttributeSet?) : Preference(con
companion object {
private fun getBackendPrettyName(context: Context, backend: Backend) = when (backend) {
is AwgQuickBackend -> context.getString(R.string.type_name_kernel_module)
is WgQuickBackend -> context.getString(R.string.type_name_kernel_module)
is GoBackend -> context.getString(R.string.type_name_go_userspace)
else -> ""
}
@@ -1,22 +1,22 @@
/*
* Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package org.amnezia.awg.preference
package com.wireguard.android.preference
import android.content.Context
import android.util.AttributeSet
import android.util.Log
import androidx.preference.Preference
import com.google.android.material.snackbar.Snackbar
import org.amnezia.awg.Application
import org.amnezia.awg.R
import org.amnezia.awg.util.AdminKnobs
import org.amnezia.awg.util.BiometricAuthenticator
import org.amnezia.awg.util.DownloadsFileSaver
import org.amnezia.awg.util.ErrorMessages
import org.amnezia.awg.util.activity
import org.amnezia.awg.util.lifecycleScope
import com.wireguard.android.Application
import com.wireguard.android.R
import com.wireguard.android.util.AdminKnobs
import com.wireguard.android.util.BiometricAuthenticator
import com.wireguard.android.util.DownloadsFileSaver
import com.wireguard.android.util.ErrorMessages
import com.wireguard.android.util.activity
import com.wireguard.android.util.lifecycleScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.async
@@ -43,7 +43,7 @@ class ZipExporterPreference(context: Context, attrs: AttributeSet?) : Preference
if (configs.isEmpty()) {
throw IllegalArgumentException(context.getString(R.string.no_tunnels_error))
}
val outputFile = downloadsFileSaver.save("amneziawg-export.zip", "application/zip", true)
val outputFile = downloadsFileSaver.save("wireguard-export.zip", "application/zip", true)
if (outputFile == null) {
withContext(Dispatchers.Main.immediate) {
isEnabled = true
@@ -54,7 +54,7 @@ class ZipExporterPreference(context: Context, attrs: AttributeSet?) : Preference
ZipOutputStream(outputFile.outputStream).use { zip ->
for (i in configs.indices) {
zip.putNextEntry(ZipEntry(tunnels[i].name + ".conf"))
zip.write(configs[i].toAwgQuickString().toByteArray(StandardCharsets.UTF_8))
zip.write(configs[i].toWgQuickString().toByteArray(StandardCharsets.UTF_8))
}
zip.closeEntry()
}
@@ -108,6 +108,6 @@ class ZipExporterPreference(context: Context, attrs: AttributeSet?) : Preference
}
companion object {
private const val TAG = "AmneziaWG/ZipExporterPreference"
private const val TAG = "WireGuard/ZipExporterPreference"
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,173 @@
/*
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package com.wireguard.android.updater
import android.content.Intent
import android.net.Uri
import android.view.View
import android.widget.Toast
import androidx.activity.result.contract.ActivityResultContracts
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.snackbar.BaseTransientBottomBar
import com.google.android.material.snackbar.Snackbar
import com.wireguard.android.R
import com.wireguard.android.util.ErrorMessages
import com.wireguard.android.util.QuantityFormatter
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import kotlin.time.Duration.Companion.seconds
class SnackbarUpdateShower(private val fragment: Fragment) {
private var lastUserIntervention: Updater.Progress.NeedsUserIntervention? = null
private val intentLauncher = fragment.registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
lastUserIntervention?.markAsDone()
}
private class SwapableSnackbar(fragment: Fragment, view: View, anchor: View?) {
private val actionSnackbar = makeSnackbar(fragment, view, anchor)
private val statusSnackbar = makeSnackbar(fragment, view, anchor)
private var showingAction: Boolean = false
private var showingStatus: Boolean = false
private fun makeSnackbar(fragment: Fragment, view: View, anchor: View?): Snackbar {
val snackbar = Snackbar.make(fragment.requireContext(), view, "", Snackbar.LENGTH_INDEFINITE)
if (anchor != null)
snackbar.anchorView = anchor
snackbar.setTextMaxLines(6)
snackbar.behavior = object : BaseTransientBottomBar.Behavior() {
override fun canSwipeDismissView(child: View): Boolean {
return false
}
}
snackbar.addCallback(object : BaseTransientBottomBar.BaseCallback<Snackbar>() {
override fun onDismissed(snackbar: Snackbar?, @DismissEvent event: Int) {
super.onDismissed(snackbar, event)
if (event == DISMISS_EVENT_MANUAL || event == DISMISS_EVENT_ACTION ||
(snackbar == actionSnackbar && !showingAction) || (snackbar == statusSnackbar && !showingStatus)
)
return
fragment.lifecycleScope.launch {
delay(5.seconds)
snackbar?.show()
}
}
})
return snackbar
}
fun showAction(text: String, action: String, listener: View.OnClickListener) {
if (showingStatus) {
showingStatus = false
statusSnackbar.dismiss()
}
actionSnackbar.setText(text)
actionSnackbar.setAction(action, listener)
if (!showingAction) {
actionSnackbar.show()
showingAction = true
}
}
fun showText(text: String) {
if (showingAction) {
showingAction = false
actionSnackbar.dismiss()
}
statusSnackbar.setText(text)
if (!showingStatus) {
statusSnackbar.show()
showingStatus = true
}
}
fun dismiss() {
actionSnackbar.dismiss()
statusSnackbar.dismiss()
showingAction = false
showingStatus = false
}
}
fun attach(view: View, anchor: View?) {
val snackbar = SwapableSnackbar(fragment, view, anchor)
val context = fragment.requireContext()
Updater.state.onEach { progress ->
when (progress) {
is Updater.Progress.Complete ->
snackbar.dismiss()
is Updater.Progress.Available ->
snackbar.showAction(context.getString(R.string.updater_avalable), context.getString(R.string.updater_action)) {
progress.update()
}
is Updater.Progress.NeedsUserIntervention -> {
lastUserIntervention = progress
intentLauncher.launch(progress.intent)
}
is Updater.Progress.Installing ->
snackbar.showText(context.getString(R.string.updater_installing))
is Updater.Progress.Rechecking ->
snackbar.showText(context.getString(R.string.updater_rechecking))
is Updater.Progress.Downloading -> {
if (progress.bytesTotal != 0UL) {
snackbar.showText(
context.getString(
R.string.updater_download_progress,
QuantityFormatter.formatBytes(progress.bytesDownloaded.toLong()),
QuantityFormatter.formatBytes(progress.bytesTotal.toLong()),
progress.bytesDownloaded.toFloat() * 100.0 / progress.bytesTotal.toFloat()
)
)
} else {
snackbar.showText(
context.getString(
R.string.updater_download_progress_nototal,
QuantityFormatter.formatBytes(progress.bytesDownloaded.toLong())
)
)
}
}
is Updater.Progress.Failure -> {
snackbar.showText(context.getString(R.string.updater_failure, ErrorMessages[progress.error]))
delay(5.seconds)
progress.retry()
}
is Updater.Progress.Corrupt -> {
MaterialAlertDialogBuilder(context)
.setTitle(R.string.updater_corrupt_title)
.setMessage(R.string.updater_corrupt_message)
.setPositiveButton(R.string.updater_corrupt_navigate) { _, _ ->
val intent = Intent(Intent.ACTION_VIEW)
intent.data = Uri.parse(progress.downloadUrl)
try {
context.startActivity(intent)
} catch (e: Throwable) {
Toast.makeText(context, ErrorMessages[e], Toast.LENGTH_SHORT).show()
}
}.setCancelable(false).setOnDismissListener {
val intent = Intent(Intent.ACTION_MAIN)
intent.addCategory(Intent.CATEGORY_HOME)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(intent)
System.exit(0)
}.show()
}
}
}.launchIn(fragment.lifecycleScope)
}
}
@@ -0,0 +1,451 @@
/*
* Copyright © 2017-2025 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package com.wireguard.android.updater
import android.Manifest
import android.app.PendingIntent
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.content.pm.PackageInstaller
import android.content.pm.PackageManager
import android.os.Build
import android.util.Base64
import android.util.Log
import androidx.core.content.ContextCompat
import androidx.core.content.IntentCompat
import com.wireguard.android.Application
import com.wireguard.android.BuildConfig
import com.wireguard.android.activity.MainActivity
import com.wireguard.android.util.UserKnobs
import com.wireguard.android.util.applicationScope
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.firstOrNull
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.io.IOException
import java.net.HttpURLConnection
import java.net.URL
import java.nio.charset.StandardCharsets
import java.security.InvalidKeyException
import java.security.InvalidParameterException
import java.security.MessageDigest
import java.util.UUID
import kotlin.math.max
import kotlin.time.Duration.Companion.minutes
import kotlin.time.Duration.Companion.seconds
object Updater {
private const val TAG = "WireGuard/Updater"
private const val UPDATE_URL_FMT = "https://download.wireguard.com/android-client/%s"
private const val APK_NAME_PREFIX = BuildConfig.APPLICATION_ID + "-"
private const val APK_NAME_SUFFIX = ".apk"
private const val LATEST_FILE = "latest.sig"
private const val RELEASE_PUBLIC_KEY_BASE64 = "RWTAzwGRYr3EC9px0Ia3fbttz8WcVN6wrOwWp2delz4el6SI8XmkKSMp"
private val CURRENT_VERSION by lazy { Version(BuildConfig.VERSION_NAME) }
private val updaterScope = CoroutineScope(Job() + Dispatchers.IO)
private fun installer(context: Context): String = try {
val packageName = context.packageName
val pm = context.packageManager
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
pm.getInstallSourceInfo(packageName).installingPackageName ?: ""
} else {
@Suppress("DEPRECATION")
pm.getInstallerPackageName(packageName) ?: ""
}
} catch (_: Throwable) {
""
}
fun installerIsGooglePlay(context: Context): Boolean = installer(context) == "com.android.vending"
sealed class Progress {
object Complete : Progress()
class Available(val version: String) : Progress() {
fun update() {
applicationScope.launch {
UserKnobs.setUpdaterNewerVersionConsented(version)
}
}
}
object Rechecking : Progress()
class Downloading(val bytesDownloaded: ULong, val bytesTotal: ULong) : Progress()
object Installing : Progress()
class NeedsUserIntervention(val intent: Intent, private val id: Int) : Progress() {
private suspend fun installerActive(): Boolean {
if (mutableState.firstOrNull() != this@NeedsUserIntervention)
return true
try {
if (Application.get().packageManager.packageInstaller.getSessionInfo(id)?.isActive == true)
return true
} catch (_: SecurityException) {
return true
}
return false
}
fun markAsDone() {
applicationScope.launch {
if (installerActive())
return@launch
delay(7.seconds)
if (installerActive())
return@launch
emitProgress(Failure(Exception("Ignored by user")))
}
}
}
class Failure(val error: Throwable) : Progress() {
fun retry() {
updaterScope.launch {
downloadAndUpdateWrapErrors()
}
}
}
class Corrupt(private val betterFile: String?) : Progress() {
val downloadUrl: String
get() = UPDATE_URL_FMT.format(betterFile ?: "")
}
}
private val mutableState = MutableStateFlow<Progress>(Progress.Complete)
val state = mutableState.asStateFlow()
private suspend fun emitProgress(progress: Progress, force: Boolean = false) {
if (force || mutableState.firstOrNull()?.javaClass != progress.javaClass)
mutableState.emit(progress)
}
private class Sha256Digest(hex: String) {
val bytes: ByteArray
init {
if (hex.length != 64)
throw InvalidParameterException("SHA256 hashes must be 32 bytes long")
bytes = hex.chunked(2).map { it.toInt(16).toByte() }.toByteArray()
}
}
@OptIn(ExperimentalUnsignedTypes::class)
private class Version(version: String) : Comparable<Version> {
val parts: ULongArray
init {
val strParts = version.split(".")
if (strParts.isEmpty())
throw InvalidParameterException("Version has no parts")
parts = ULongArray(strParts.size)
for (i in parts.indices) {
parts[i] = strParts[i].toULong()
}
}
override fun toString(): String {
return parts.joinToString(".")
}
override fun compareTo(other: Version): Int {
for (i in 0 until max(parts.size, other.parts.size)) {
val lhsPart = if (i < parts.size) parts[i] else 0UL
val rhsPart = if (i < other.parts.size) other.parts[i] else 0UL
if (lhsPart > rhsPart)
return 1
else if (lhsPart < rhsPart)
return -1
}
return 0
}
}
private class Update(val fileName: String, val version: Version, val hash: Sha256Digest)
private fun versionOfFile(name: String): Version? {
if (!name.startsWith(APK_NAME_PREFIX) || !name.endsWith(APK_NAME_SUFFIX))
return null
return try {
Version(name.substring(APK_NAME_PREFIX.length, name.length - APK_NAME_SUFFIX.length))
} catch (_: Throwable) {
null
}
}
private fun verifySignedFileList(signifyDigest: String): List<Update> {
val updates = ArrayList<Update>(1)
val publicKeyBytes = Base64.decode(RELEASE_PUBLIC_KEY_BASE64, Base64.DEFAULT)
if (publicKeyBytes == null || publicKeyBytes.size != 32 + 10 || publicKeyBytes[0] != 'E'.code.toByte() || publicKeyBytes[1] != 'd'.code.toByte())
throw InvalidKeyException("Invalid public key")
val lines = signifyDigest.split("\n", limit = 3)
if (lines.size != 3)
throw InvalidParameterException("Invalid signature format: too few lines")
if (!lines[0].startsWith("untrusted comment: "))
throw InvalidParameterException("Invalid signature format: missing comment")
val signatureBytes = Base64.decode(lines[1], Base64.DEFAULT)
if (signatureBytes == null || signatureBytes.size != 64 + 10)
throw InvalidParameterException("Invalid signature format: wrong sized or missing signature")
for (i in 0..9) {
if (signatureBytes[i] != publicKeyBytes[i])
throw InvalidParameterException("Invalid signature format: wrong signer")
}
if (!Ed25519.verify(
lines[2].toByteArray(StandardCharsets.UTF_8),
signatureBytes.sliceArray(10 until 10 + 64),
publicKeyBytes.sliceArray(10 until 10 + 32)
)
)
throw SecurityException("Invalid signature")
for (line in lines[2].split("\n").dropLastWhile { it.isEmpty() }) {
val components = line.split(" ", limit = 2)
if (components.size != 2)
throw InvalidParameterException("Invalid file list format: too few components")
/* If version is null, it's not a file we understand, but still a legitimate entry, so don't throw. */
val version = versionOfFile(components[1]) ?: continue
updates.add(Update(components[1], version, Sha256Digest(components[0])))
}
return updates
}
private fun checkForUpdates(): Update? {
val connection = URL(UPDATE_URL_FMT.format(LATEST_FILE)).openConnection() as HttpURLConnection
connection.setRequestProperty("User-Agent", Application.USER_AGENT)
connection.connect()
if (connection.responseCode != HttpURLConnection.HTTP_OK)
throw IOException(connection.responseMessage)
var fileListBytes = ByteArray(1024 * 512 /* 512 KiB */)
connection.inputStream.use {
val len = it.read(fileListBytes)
if (len <= 0)
throw IOException("File list is empty")
fileListBytes = fileListBytes.sliceArray(0 until len)
}
return verifySignedFileList(fileListBytes.decodeToString()).maxByOrNull { it.version }
}
private suspend fun downloadAndUpdate() = withContext(Dispatchers.IO) {
val receiver = InstallReceiver()
val context = Application.get().applicationContext
val pendingIntent = withContext(Dispatchers.Main) {
ContextCompat.registerReceiver(context, receiver, IntentFilter(receiver.sessionId), ContextCompat.RECEIVER_NOT_EXPORTED)
PendingIntent.getBroadcast(
context,
0,
Intent(receiver.sessionId).setPackage(context.packageName),
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE
)
}
emitProgress(Progress.Rechecking)
val update = checkForUpdates()
if (update == null || update.version <= CURRENT_VERSION) {
emitProgress(Progress.Complete)
return@withContext
}
emitProgress(Progress.Downloading(0UL, 0UL), true)
val connection = URL(UPDATE_URL_FMT.format(update.fileName)).openConnection() as HttpURLConnection
connection.setRequestProperty("User-Agent", Application.USER_AGENT)
connection.connect()
if (connection.responseCode != HttpURLConnection.HTTP_OK)
throw IOException("Update could not be fetched: ${connection.responseCode}")
var downloadedByteLen: ULong = 0UL
val totalByteLen = (if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) connection.contentLengthLong else connection.contentLength).toLong().toULong()
val fileBytes = ByteArray(1024 * 32 /* 32 KiB */)
val digest = MessageDigest.getInstance("SHA-256")
emitProgress(Progress.Downloading(downloadedByteLen, totalByteLen), true)
val installer = context.packageManager.packageInstaller
val params = PackageInstaller.SessionParams(PackageInstaller.SessionParams.MODE_FULL_INSTALL)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)
params.setRequireUserAction(PackageInstaller.SessionParams.USER_ACTION_NOT_REQUIRED)
params.setAppPackageName(context.packageName) /* Enforces updates; disallows new apps. */
val session = installer.openSession(installer.createSession(params))
var sessionFailure = true
try {
val installDest = session.openWrite(receiver.sessionId, 0, -1)
installDest.use { dest ->
connection.inputStream.use { src ->
while (true) {
val readLen = src.read(fileBytes)
if (readLen <= 0)
break
digest.update(fileBytes, 0, readLen)
dest.write(fileBytes, 0, readLen)
downloadedByteLen += readLen.toUInt()
emitProgress(Progress.Downloading(downloadedByteLen, totalByteLen), true)
if (downloadedByteLen >= 1024UL * 1024UL * 100UL /* 100 MiB */)
throw IOException("File too large")
}
}
}
emitProgress(Progress.Installing)
if (!digest.digest().contentEquals(update.hash.bytes))
throw SecurityException("Update has invalid hash")
sessionFailure = false
} finally {
if (sessionFailure) {
session.abandon()
session.close()
}
}
session.commit(pendingIntent.intentSender)
session.close()
}
private var updating = false
private suspend fun downloadAndUpdateWrapErrors() {
if (updating)
return
updating = true
try {
downloadAndUpdate()
} catch (e: Throwable) {
Log.e(TAG, "Update failure", e)
emitProgress(Progress.Failure(e))
}
updating = false
}
private class InstallReceiver : BroadcastReceiver() {
val sessionId = UUID.randomUUID().toString()
override fun onReceive(context: Context, intent: Intent) {
if (sessionId != intent.action)
return
when (val status = intent.getIntExtra(PackageInstaller.EXTRA_STATUS, PackageInstaller.STATUS_FAILURE_INVALID)) {
PackageInstaller.STATUS_PENDING_USER_ACTION -> {
val id = intent.getIntExtra(PackageInstaller.EXTRA_SESSION_ID, 0)
val userIntervention = IntentCompat.getParcelableExtra(intent, Intent.EXTRA_INTENT, Intent::class.java)!!
applicationScope.launch {
emitProgress(Progress.NeedsUserIntervention(userIntervention, id))
}
}
PackageInstaller.STATUS_SUCCESS -> {
applicationScope.launch {
emitProgress(Progress.Complete)
}
context.applicationContext.unregisterReceiver(this)
}
else -> {
val id = intent.getIntExtra(PackageInstaller.EXTRA_SESSION_ID, 0)
try {
context.applicationContext.packageManager.packageInstaller.abandonSession(id)
} catch (_: SecurityException) {
}
val message = intent.getStringExtra(PackageInstaller.EXTRA_STATUS_MESSAGE) ?: "Installation error $status"
applicationScope.launch {
val e = Exception(message)
Log.e(TAG, "Update failure", e)
emitProgress(Progress.Failure(e))
}
context.applicationContext.unregisterReceiver(this)
}
}
}
}
fun monitorForUpdates() {
if (BuildConfig.DEBUG)
return
val context = Application.get()
if (installerIsGooglePlay(context))
return
if (if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
@Suppress("DEPRECATION")
context.packageManager.getPackageInfo(context.packageName, PackageManager.GET_PERMISSIONS)
} else {
context.packageManager.getPackageInfo(context.packageName, PackageManager.PackageInfoFlags.of(PackageManager.GET_PERMISSIONS.toLong()))
}.requestedPermissions?.contains(Manifest.permission.REQUEST_INSTALL_PACKAGES) != true
) {
if (installer(context).isNotEmpty()) {
updaterScope.launch {
val update = try {
checkForUpdates()
} catch (_: Throwable) {
null
}
emitProgress(Progress.Corrupt(update?.fileName))
}
}
return
}
updaterScope.launch {
if (UserKnobs.updaterNewerVersionSeen.firstOrNull()?.let { Version(it) > CURRENT_VERSION } == true)
return@launch
var waitTime = 15
while (true) {
try {
val update = checkForUpdates() ?: continue
if (update.version > CURRENT_VERSION) {
Log.i(TAG, "Update available: ${update.version}")
UserKnobs.setUpdaterNewerVersionSeen(update.version.toString())
return@launch
}
} catch (_: Throwable) {
}
delay(waitTime.minutes)
waitTime = 45
}
}
UserKnobs.updaterNewerVersionSeen.onEach { ver ->
if (
ver != null &&
Version(ver) > CURRENT_VERSION &&
UserKnobs.updaterNewerVersionConsented.firstOrNull()?.let { Version(it) > CURRENT_VERSION } != true
)
emitProgress(Progress.Available(ver))
}.launchIn(applicationScope)
UserKnobs.updaterNewerVersionConsented.onEach { ver ->
if (ver != null && Version(ver) > CURRENT_VERSION)
updaterScope.launch {
downloadAndUpdateWrapErrors()
}
}.launchIn(applicationScope)
}
class AppUpdatedReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
if (intent.action != Intent.ACTION_MY_PACKAGE_REPLACED)
return
if (installer(context) != context.packageName)
return
/* TODO: does not work because of restrictions placed on broadcast receivers. */
val start = Intent(context, MainActivity::class.java)
start.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
start.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(start)
}
}
}

Some files were not shown because too many files have changed in this diff Show More