diff options
author | Samuel Holland <samuel@sholland.org> | 2017-11-24 21:13:55 -0600 |
---|---|---|
committer | Samuel Holland <samuel@sholland.org> | 2017-11-24 21:16:37 -0600 |
commit | 50a7a12de279574dd15f4db5cf5ea7aa984b7c80 (patch) | |
tree | dd1d5cad145048cb912195902e2a5fd364964a17 /app | |
parent | 69d4fe9a8120fd10e144bac0bc5f7083ee1a283a (diff) |
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>
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/AndroidManifest.xml | 12 | ||||
-rw-r--r-- | app/src/main/java/com/wireguard/android/BaseConfigActivity.java | 1 | ||||
-rw-r--r-- | app/src/main/java/com/wireguard/android/BaseConfigFragment.java | 1 | ||||
-rw-r--r-- | app/src/main/java/com/wireguard/android/BootCompletedReceiver.java | 2 | ||||
-rw-r--r-- | app/src/main/java/com/wireguard/android/ConfigActivity.java | 1 | ||||
-rw-r--r-- | app/src/main/java/com/wireguard/android/ConfigEditFragment.java | 1 | ||||
-rw-r--r-- | app/src/main/java/com/wireguard/android/ConfigListFragment.java | 1 | ||||
-rw-r--r-- | app/src/main/java/com/wireguard/android/ConfigListPreference.java | 2 | ||||
-rw-r--r-- | app/src/main/java/com/wireguard/android/QuickTileService.java | 1 | ||||
-rw-r--r-- | app/src/main/java/com/wireguard/android/backends/RootShell.java (renamed from app/src/main/java/com/wireguard/android/RootShell.java) | 2 | ||||
-rw-r--r-- | app/src/main/java/com/wireguard/android/backends/VpnService.java (renamed from app/src/main/java/com/wireguard/android/VpnService.java) | 14 | ||||
-rw-r--r-- | app/src/main/res/layout/config_list_item.xml | 2 |
12 files changed, 26 insertions, 14 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1563d312..3ba0a77d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -12,6 +12,11 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@android:style/Theme.Material.Light.DarkActionBar"> + + <activity + android:name=".AddActivity" + android:label="@string/add_activity_title" + android:parentActivityName=".ConfigActivity" /> <activity android:name=".ConfigActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> @@ -20,10 +25,6 @@ </intent-filter> </activity> <activity - android:name=".AddActivity" - android:label="@string/add_activity_title" - android:parentActivityName=".ConfigActivity" /> - <activity android:name=".SettingsActivity" android:label="@string/settings"> <intent-filter> @@ -44,12 +45,13 @@ <intent-filter> <action android:name="android.service.quicksettings.action.QS_TILE" /> </intent-filter> + <meta-data android:name="android.service.quicksettings.ACTIVE_TILE" android:value="true" /> </service> <service - android:name=".VpnService" + android:name=".backends.VpnService" android:exported="false" /> </application> diff --git a/app/src/main/java/com/wireguard/android/BaseConfigActivity.java b/app/src/main/java/com/wireguard/android/BaseConfigActivity.java index 17ca3b6a..14a9384c 100644 --- a/app/src/main/java/com/wireguard/android/BaseConfigActivity.java +++ b/app/src/main/java/com/wireguard/android/BaseConfigActivity.java @@ -8,6 +8,7 @@ import android.content.ServiceConnection; import android.os.Bundle; import android.os.IBinder; +import com.wireguard.android.backends.VpnService; import com.wireguard.config.Config; /** diff --git a/app/src/main/java/com/wireguard/android/BaseConfigFragment.java b/app/src/main/java/com/wireguard/android/BaseConfigFragment.java index 42912648..c92d127e 100644 --- a/app/src/main/java/com/wireguard/android/BaseConfigFragment.java +++ b/app/src/main/java/com/wireguard/android/BaseConfigFragment.java @@ -3,6 +3,7 @@ package com.wireguard.android; import android.app.Fragment; import android.os.Bundle; +import com.wireguard.android.backends.VpnService; import com.wireguard.config.Config; /** diff --git a/app/src/main/java/com/wireguard/android/BootCompletedReceiver.java b/app/src/main/java/com/wireguard/android/BootCompletedReceiver.java index 68cb5f1f..0bf28912 100644 --- a/app/src/main/java/com/wireguard/android/BootCompletedReceiver.java +++ b/app/src/main/java/com/wireguard/android/BootCompletedReceiver.java @@ -4,6 +4,8 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; +import com.wireguard.android.backends.VpnService; + public class BootCompletedReceiver extends BroadcastReceiver { @Override diff --git a/app/src/main/java/com/wireguard/android/ConfigActivity.java b/app/src/main/java/com/wireguard/android/ConfigActivity.java index 881f3f9a..439f77da 100644 --- a/app/src/main/java/com/wireguard/android/ConfigActivity.java +++ b/app/src/main/java/com/wireguard/android/ConfigActivity.java @@ -8,6 +8,7 @@ import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; +import com.wireguard.android.backends.VpnService; import com.wireguard.config.Config; /** diff --git a/app/src/main/java/com/wireguard/android/ConfigEditFragment.java b/app/src/main/java/com/wireguard/android/ConfigEditFragment.java index 1edae9cc..f29f20fe 100644 --- a/app/src/main/java/com/wireguard/android/ConfigEditFragment.java +++ b/app/src/main/java/com/wireguard/android/ConfigEditFragment.java @@ -14,6 +14,7 @@ import android.view.ViewGroup; import android.view.inputmethod.InputMethodManager; import android.widget.Toast; +import com.wireguard.android.backends.VpnService; import com.wireguard.android.databinding.ConfigEditFragmentBinding; import com.wireguard.config.Config; diff --git a/app/src/main/java/com/wireguard/android/ConfigListFragment.java b/app/src/main/java/com/wireguard/android/ConfigListFragment.java index 88d12745..1067dc73 100644 --- a/app/src/main/java/com/wireguard/android/ConfigListFragment.java +++ b/app/src/main/java/com/wireguard/android/ConfigListFragment.java @@ -13,6 +13,7 @@ import android.widget.AbsListView; import android.widget.AdapterView; import android.widget.ListView; +import com.wireguard.android.backends.VpnService; import com.wireguard.android.bindings.ObservableMapAdapter; import com.wireguard.android.databinding.ConfigListFragmentBinding; import com.wireguard.config.Config; diff --git a/app/src/main/java/com/wireguard/android/ConfigListPreference.java b/app/src/main/java/com/wireguard/android/ConfigListPreference.java index 38421610..131b0a43 100644 --- a/app/src/main/java/com/wireguard/android/ConfigListPreference.java +++ b/app/src/main/java/com/wireguard/android/ConfigListPreference.java @@ -4,6 +4,8 @@ import android.content.Context; import android.preference.ListPreference; import android.util.AttributeSet; +import com.wireguard.android.backends.VpnService; + import java.util.Set; /** diff --git a/app/src/main/java/com/wireguard/android/QuickTileService.java b/app/src/main/java/com/wireguard/android/QuickTileService.java index ddadf29d..9f97c6c4 100644 --- a/app/src/main/java/com/wireguard/android/QuickTileService.java +++ b/app/src/main/java/com/wireguard/android/QuickTileService.java @@ -13,6 +13,7 @@ import android.preference.PreferenceManager; import android.service.quicksettings.Tile; import android.service.quicksettings.TileService; +import com.wireguard.android.backends.VpnService; import com.wireguard.config.Config; @TargetApi(Build.VERSION_CODES.N) diff --git a/app/src/main/java/com/wireguard/android/RootShell.java b/app/src/main/java/com/wireguard/android/backends/RootShell.java index 973a5d0c..0b529065 100644 --- a/app/src/main/java/com/wireguard/android/RootShell.java +++ b/app/src/main/java/com/wireguard/android/backends/RootShell.java @@ -1,4 +1,4 @@ -package com.wireguard.android; +package com.wireguard.android.backends; import android.content.Context; import android.util.Log; diff --git a/app/src/main/java/com/wireguard/android/VpnService.java b/app/src/main/java/com/wireguard/android/backends/VpnService.java index 0a828bc0..25eb4ade 100644 --- a/app/src/main/java/com/wireguard/android/VpnService.java +++ b/app/src/main/java/com/wireguard/android/backends/VpnService.java @@ -1,4 +1,4 @@ -package com.wireguard.android; +package com.wireguard.android.backends; import android.app.Service; import android.content.ComponentName; @@ -14,6 +14,7 @@ import android.preference.PreferenceManager; import android.service.quicksettings.TileService; import android.util.Log; +import com.wireguard.android.QuickTileService; import com.wireguard.android.bindings.ObservableSortedMap; import com.wireguard.android.bindings.ObservableTreeMap; import com.wireguard.config.Config; @@ -45,11 +46,6 @@ public class VpnService extends Service private static final String TAG = "VpnService"; private static VpnService instance; - - public static VpnService getInstance() { - return instance; - } - private final IBinder binder = new Binder(); private final ObservableTreeMap<String, Config> configurations = new ObservableTreeMap<>(); private final Set<String> enabledConfigs = new HashSet<>(); @@ -57,6 +53,10 @@ public class VpnService extends Service private String primaryName; private RootShell rootShell; + public static VpnService getInstance() { + return instance; + } + /** * Add a new configuration to the set of known configurations. The configuration will initially * be disabled. The configuration's name must be unique within the set of known configurations. @@ -406,11 +406,11 @@ public class VpnService extends Service } private class ConfigUpdater extends AsyncTask<Void, Void, Boolean> { - private Config knownConfig; private final Config newConfig; private final String newName; private final String oldName; private final Boolean shouldConnect; + private Config knownConfig; private ConfigUpdater(final Config knownConfig, final Config newConfig, final Boolean shouldConnect) { diff --git a/app/src/main/res/layout/config_list_item.xml b/app/src/main/res/layout/config_list_item.xml index cdc0723a..578db833 100644 --- a/app/src/main/res/layout/config_list_item.xml +++ b/app/src/main/res/layout/config_list_item.xml @@ -5,7 +5,7 @@ <import type="android.graphics.Typeface" /> - <import type="com.wireguard.android.VpnService" /> + <import type="com.wireguard.android.backends.VpnService" /> <variable name="key" |