summaryrefslogtreecommitdiffhomepage
path: root/app/src/main/java/com/wireguard/android
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/com/wireguard/android')
-rw-r--r--app/src/main/java/com/wireguard/android/ProfileService.java10
1 files changed, 8 insertions, 2 deletions
diff --git a/app/src/main/java/com/wireguard/android/ProfileService.java b/app/src/main/java/com/wireguard/android/ProfileService.java
index 2d0e55eb..d5c882db 100644
--- a/app/src/main/java/com/wireguard/android/ProfileService.java
+++ b/app/src/main/java/com/wireguard/android/ProfileService.java
@@ -16,6 +16,7 @@ import java.io.FileOutputStream;
import java.io.FilenameFilter;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
+import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
@@ -132,8 +133,13 @@ public class ProfileService extends Service {
protected List<Profile> doInBackground(File... files) {
final List<String> interfaceNames = new LinkedList<>();
final List<Profile> loadedProfiles = new LinkedList<>();
- final String command = "ip -br link show type wireguard | cut -d' ' -f1";
- if (RootShell.run(interfaceNames, command) != 0) {
+ final String command = "wg show interfaces";
+ if (RootShell.run(interfaceNames, command) == 0 && interfaceNames.size() == 1) {
+ // wg puts all interface names on the same line. Split them into separate elements.
+ final String nameList = interfaceNames.get(0);
+ Collections.addAll(interfaceNames, nameList.split(" "));
+ interfaceNames.remove(0);
+ } else {
interfaceNames.clear();
Log.w(TAG, "Can't enumerate network interfaces. All profiles will appear down.");
}