0
0
Fork 0
mirror of https://github.com/YTVanced/VancedMicroG synced 2024-11-04 18:15:04 +00:00

McsService: only send to the output stream if it is alive

The output stream handler thread might not be alive, this occurs
reproducibly when connecting fails and a tear down is initiated.
Messages shouldn't be sent when the output handler thread is not alive
(triggers an expection which is catched but logged), this check avoids
this unless some special race condition occurs. Dropping the messages
shouldn't hurt (they were dropped anyway).
This commit is contained in:
Michael Hamann 2016-01-17 15:56:03 +01:00
parent 3636f18d84
commit 48809464a7

View file

@ -323,7 +323,7 @@ public class McsService extends Service implements Handler.Callback {
private void sendOutputStream(int what, Object obj) { private void sendOutputStream(int what, Object obj) {
McsOutputStream os = outputStream; McsOutputStream os = outputStream;
if (os != null) { if (os != null && os.isAlive()) {
Handler outputHandler = os.getHandler(); Handler outputHandler = os.getHandler();
if (outputHandler != null) if (outputHandler != null)
outputHandler.sendMessage(outputHandler.obtainMessage(what, obj)); outputHandler.sendMessage(outputHandler.obtainMessage(what, obj));