summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSamuel Holland <samuel@sholland.org>2018-01-08 23:14:07 -0600
committerSamuel Holland <samuel@sholland.org>2018-01-08 23:39:32 -0600
commitba30d46e08d2c2186d99f1b398f10701dea86eba (patch)
treefecb181bb47a6bd7b05b2891815d417ca664adbb
parent1cfb938dd18526b4d961dfc8ac374ac678724c18 (diff)
WgQuickBackend: Inline resolveState()
Signed-off-by: Samuel Holland <samuel@sholland.org>
-rw-r--r--app/src/main/java/com/wireguard/android/backend/WgQuickBackend.java15
1 files changed, 5 insertions, 10 deletions
diff --git a/app/src/main/java/com/wireguard/android/backend/WgQuickBackend.java b/app/src/main/java/com/wireguard/android/backend/WgQuickBackend.java
index cb5eae5d..ed55f097 100644
--- a/app/src/main/java/com/wireguard/android/backend/WgQuickBackend.java
+++ b/app/src/main/java/com/wireguard/android/backend/WgQuickBackend.java
@@ -35,12 +35,6 @@ public final class WgQuickBackend implements Backend {
this.rootShell = rootShell;
}
- private static State resolveState(final State currentState, State requestedState) {
- if (requestedState == State.TOGGLE)
- requestedState = currentState == State.UP ? State.DOWN : State.UP;
- return requestedState;
- }
-
@Override
public Config applyConfig(final Tunnel tunnel, final Config config) {
if (tunnel.getState() == State.UP)
@@ -74,14 +68,15 @@ public final class WgQuickBackend implements Backend {
}
@Override
- public State setState(final Tunnel tunnel, final State state) throws Exception {
+ public State setState(final Tunnel tunnel, State state) throws Exception {
Log.v(TAG, "Requested state change to " + state + " for tunnel " + tunnel.getName());
final State originalState = getState(tunnel);
- final State resolvedState = resolveState(originalState, state);
- if (resolvedState == originalState)
+ if (state == State.TOGGLE)
+ state = originalState == State.UP ? State.DOWN : State.UP;
+ if (state == originalState)
return originalState;
final int result;
- if (resolvedState == State.UP) {
+ if (state == State.UP) {
if (!new File("/sys/module/wireguard").exists())
throw new ErrnoException("WireGuard module not loaded", OsConstants.ENODEV);
// FIXME: Assumes file layout from FileConfigStore. Use a temporary file.