Display and control your Android device
Avoid server stacktraces on close
Romain Vimontc683872bbcce
diff --git a/server/src/main/java/com/genymobile/scrcpy/ScrCpyServer.java b/server/src/main/java/com/genymobile/scrcpy/ScrCpyServer.javaindex f4dd793f..9895c535 100644--- a/server/src/main/java/com/genymobile/scrcpy/ScrCpyServer.java+++ b/server/src/main/java/com/genymobile/scrcpy/ScrCpyServer.java@@ -1,6 +1,7 @@package com.genymobile.scrcpy;import java.io.IOException;+import java.lang.reflect.InvocationTargetException;public final class ScrCpyServer {@@ -20,7 +21,7 @@ public final class ScrCpyServer {// synchronousscreenEncoder.streamScreen(device, connection.getOutputStream());} catch (IOException e) {- Ln.e("Screen streaming interrupted", e);+ Ln.w("Screen streaming stopped");}}}@@ -32,7 +33,7 @@ public final class ScrCpyServer {try {new EventController(device, connection).control();} catch (IOException e) {- Ln.e("Exception from event controller", e);+ Ln.w("Event controller stopped");}}}).start();@@ -60,6 +61,13 @@ 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);}});