summaryrefslogtreecommitdiffhomepage
path: root/app/src/main/java/com/wireguard/android
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-01-09 15:19:50 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2018-01-09 15:19:50 +0100
commit23c09eb655ed779b08b8d1e4542a6bd60c83ffba (patch)
tree988fae878900f40e1be73bb9a036b666b22c7cb6 /app/src/main/java/com/wireguard/android
parent14638b10ae873478cac6c1fbc233e024242db10a (diff)
RootShell: hoist out synchronization
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app/src/main/java/com/wireguard/android')
-rw-r--r--app/src/main/java/com/wireguard/android/util/RootShell.java18
1 files changed, 7 insertions, 11 deletions
diff --git a/app/src/main/java/com/wireguard/android/util/RootShell.java b/app/src/main/java/com/wireguard/android/util/RootShell.java
index 910fa7ae..f5eb440f 100644
--- a/app/src/main/java/com/wireguard/android/util/RootShell.java
+++ b/app/src/main/java/com/wireguard/android/util/RootShell.java
@@ -57,13 +57,11 @@ public class RootShell {
return false;
}
- public boolean isRunning() {
+ public synchronized boolean isRunning() {
try {
// Throws an exception if the process hasn't finished yet.
- synchronized (this) {
- if (process != null)
- process.exitValue();
- }
+ if (process != null)
+ process.exitValue();
} catch (final IllegalThreadStateException ignored) {
// The existing process is still running.
return true;
@@ -149,12 +147,10 @@ public class RootShell {
}
}
- public void stop() throws IOException {
- synchronized (this) {
- if (process != null) {
- process.destroy();
- process = null;
- }
+ public synchronized void stop() throws IOException {
+ if (process != null) {
+ process.destroy();
+ process = null;
}
}