mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-08-03 22:58:51 +00:00
Log controller handling errors
On close, the controller is expected to throw an IOException because the socket is closed, so the exception was ignored. However, message handling actions may also throw IOException, and they must not be silently ignored. PR #4473 <https://github.com/Genymobile/scrcpy/pull/4473>
This commit is contained in:
parent
604e59ac7b
commit
4d5b67cc80
1 changed files with 15 additions and 5 deletions
|
@ -81,8 +81,9 @@ public class Controller implements AsyncProcessor {
|
||||||
SystemClock.sleep(500);
|
SystemClock.sleep(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!Thread.currentThread().isInterrupted()) {
|
boolean alive = true;
|
||||||
handleEvent();
|
while (!Thread.currentThread().isInterrupted() && alive) {
|
||||||
|
alive = handleEvent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +93,7 @@ public class Controller implements AsyncProcessor {
|
||||||
try {
|
try {
|
||||||
control();
|
control();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// this is expected on close
|
Ln.e("Controller error", e);
|
||||||
} finally {
|
} finally {
|
||||||
Ln.d("Controller stopped");
|
Ln.d("Controller stopped");
|
||||||
listener.onTerminated(true);
|
listener.onTerminated(true);
|
||||||
|
@ -122,8 +123,15 @@ public class Controller implements AsyncProcessor {
|
||||||
return sender;
|
return sender;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleEvent() throws IOException {
|
private boolean handleEvent() throws IOException {
|
||||||
ControlMessage msg = controlChannel.recv();
|
ControlMessage msg;
|
||||||
|
try {
|
||||||
|
msg = controlChannel.recv();
|
||||||
|
} catch (IOException e) {
|
||||||
|
// this is expected on close
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
switch (msg.getType()) {
|
switch (msg.getType()) {
|
||||||
case ControlMessage.TYPE_INJECT_KEYCODE:
|
case ControlMessage.TYPE_INJECT_KEYCODE:
|
||||||
if (device.supportsInputEvents()) {
|
if (device.supportsInputEvents()) {
|
||||||
|
@ -185,6 +193,8 @@ public class Controller implements AsyncProcessor {
|
||||||
default:
|
default:
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean injectKeycode(int action, int keycode, int repeat, int metaState) {
|
private boolean injectKeycode(int action, int keycode, int repeat, int metaState) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue