aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/app/src/main/java/com/wireguard/android/backend
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/com/wireguard/android/backend')
-rw-r--r--app/src/main/java/com/wireguard/android/backend/WgQuickBackend.java13
1 files changed, 7 insertions, 6 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 5eaf437d..ab6a6199 100644
--- a/app/src/main/java/com/wireguard/android/backend/WgQuickBackend.java
+++ b/app/src/main/java/com/wireguard/android/backend/WgQuickBackend.java
@@ -52,8 +52,12 @@ public final class WgQuickBackend implements Backend {
public Set<String> enumerate() {
final List<String> output = new ArrayList<>();
// Don't throw an exception here or nothing will show up in the UI.
- if (rootShell.run(output, "wg show interfaces") != 0 || output.isEmpty())
+ try {
+ if (rootShell.run(output, "wg show interfaces") != 0 || output.isEmpty())
+ return Collections.emptySet();
+ } catch (Exception e) {
return Collections.emptySet();
+ }
// wg puts all interface names on the same line. Split them into separate elements.
return Stream.of(output.get(0).split(" ")).collect(Collectors.toUnmodifiableSet());
}
@@ -86,11 +90,8 @@ public final class WgQuickBackend implements Backend {
} else {
result = rootShell.run(null, String.format("wg-quick down '%s'", tunnel.getName()));
}
- if (result != 0) {
- final String message = result == OsConstants.EACCES ?
- "Root access unavailable" : "wg-quick failed";
- throw new Exception(message);
- }
+ if (result != 0)
+ throw new Exception("wg-quick failed");
return getState(tunnel);
}
}