Display and control your Android device
Terminate event controller thread on EOF
Romain Vimont37af0c80765b
diff --git a/server/src/main/java/com/genymobile/scrcpy/ControlEventReader.java b/server/src/main/java/com/genymobile/scrcpy/ControlEventReader.javaindex 4d412f9b..c752c6cd 100644--- a/server/src/main/java/com/genymobile/scrcpy/ControlEventReader.java+++ b/server/src/main/java/com/genymobile/scrcpy/ControlEventReader.java@@ -1,5 +1,6 @@package com.genymobile.scrcpy;+import java.io.EOFException;import java.io.IOException;import java.io.InputStream;import java.nio.ByteBuffer;@@ -28,7 +29,7 @@ public class ControlEventReader {return buffer.remaining() == rawBuffer.length;}- public boolean readFrom(InputStream input) throws IOException {+ public void readFrom(InputStream input) throws IOException {if (isFull()) {throw new IllegalStateException("Buffer full, call next() to consume");}@@ -36,11 +37,10 @@ public class ControlEventReader {int head = buffer.position();int r = input.read(rawBuffer, head, rawBuffer.length - head);if (r == -1) {- return false;+ throw new EOFException("Event controller socket closed");}buffer.position(head + r);buffer.flip();- return true;}public ControlEvent next() {diff --git a/server/src/main/java/com/genymobile/scrcpy/ScrCpyServer.java b/server/src/main/java/com/genymobile/scrcpy/ScrCpyServer.javaindex 61f84451..1476d22f 100644--- a/server/src/main/java/com/genymobile/scrcpy/ScrCpyServer.java+++ b/server/src/main/java/com/genymobile/scrcpy/ScrCpyServer.java@@ -1,7 +1,6 @@package com.genymobile.scrcpy;import java.io.IOException;-import java.lang.reflect.InvocationTargetException;public final class ScrCpyServer {@@ -63,13 +62,6 @@ public final class ScrCpyServer {Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {@Overridepublic void uncaughtException(Thread t, Throwable e) {- if (e instanceof AssertionError && e.getCause() instanceof InvocationTargetException) {- // WORKAROUND- // When we call a method of the framework by reflection, it may throw an InvocationTargetException- // (that we wrap into an AssertionError) if this process is being killed.- // To avoid the stacktrace on close, do not log these errors.- return;- }Ln.e("Exception on thread " + t, e);}});