Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/com/cgutman/adblib/AdbConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,15 @@ public void run() {
case AdbProtocol.CMD_OKAY:
case AdbProtocol.CMD_WRTE:
case AdbProtocol.CMD_CLSE:
{
AdbStream waitingStream;

/* We must ignore all packets when not connected */
if (!conn.connected)
continue;

/* Get the stream object corresponding to the packet */
AdbStream waitingStream = openStreams.get(msg.arg1);
waitingStream = openStreams.get(msg.arg1);
if (waitingStream == null)
continue;

Expand All @@ -164,16 +167,15 @@ else if (msg.command == AdbProtocol.CMD_WRTE)
}
else if (msg.command == AdbProtocol.CMD_CLSE)
{
/* He doesn't like us anymore :-( */
conn.openStreams.remove(msg.arg1);

/* Notify readers and writers */
waitingStream.notifyClose();

break;
}
}

break;
continue;
}
case AdbProtocol.CMD_AUTH:

byte[] packet;
Expand All @@ -199,7 +201,7 @@ else if (msg.command == AdbProtocol.CMD_CLSE)
conn.outputStream.write(packet);
conn.outputStream.flush();
}
break;
continue;

case AdbProtocol.CMD_CNXN:
synchronized (conn) {
Expand All @@ -210,22 +212,20 @@ else if (msg.command == AdbProtocol.CMD_CLSE)
conn.connected = true;
conn.notifyAll();
}
break;

default:
/* Unrecognized packet, just drop it */
break;
continue;
}
break;
} catch (Exception e) {
/* The cleanup is taken care of by a combination of this thread
* and close() */
break;
}
}

}
public void interrupt() {
/* This thread takes care of cleaning up pending streams */
synchronized (conn) {
cleanupStreams();
conn.cleanupStreams();
conn.notifyAll();
conn.connectAttempted = false;
}
Expand Down