cgutman / AdbLib

A Java library implementation of the ADB network protocol
BSD 3-Clause "New" or "Revised" License
467 stars 144 forks source link

Just a question #1

Open wuxudong opened 10 years ago

wuxudong commented 10 years ago

Hello I am a newbie in android. There are several question about adblib.

  1. In my opinion, communication in one socket connection is sequential, there should be only at most one active open stream in AdbConnection. So why there is openStreams:HashMap in AdbConnection?
  2. If communication in one socket connection is sequential, Isn't blocking read and write simpler than multithread/wait/notify ? Why there is extra connection Thread handling message reading? Thanks a lot
cgutman commented 10 years ago

Yes, socket communication is sequential and blocking, but ADB multiplexes multiple streams over the same socket. This is why the separate thread and hash map are necessary. The connection thread reads from the socket and puts the data in the appropriate stream. The connection thread also handles authentication requests which aren’t stream-related at all.

wuxudong commented 10 years ago

I got your meanings. Thanks a lot. Is there any java implementation of adb file-sync protocol (adb push/pull) ? I can't find one.